POP3: Download the Mail Header Only

When retrieving email messages using POP3, it’s possible to retrieve just the message headers (which include information such as the sender, subject, and date) without downloading the entire message body.

Retrieving just the message headers can be helpful when you want to quickly scan the list of messages in your mailbox to decide which ones to download and read in full.

Starting with 4D v20, a new parameter is added to the .getMail() function of the POP3 transporter to receive your emails without the body. This function can be even more helpful if you use Gmail because it does not trigger the deletion of read emails.

To download the email headers with POP3, you need to use .getMail() function with its second parameter to true:

$param:=New object()
$param.authenticationMode:=POP3 authentication OAUTH2
$transporter:=POP3 New transporter($param)
// Gets the headers of the email
$mail:=$transporter.getMail($mailNumber; True)

It returns a mail object without the body parts:

Check out this feature with the documentation for more details!

Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.