Archived Forum Post

Index of archived forum posts

Question:

How to get the Message-ID of the Email that is Sent?

Oct 27 '16 at 06:19

When I use the SendEmail method with Chilkat MailMan how can I get the Message-ID of the sent mail? I see it in the SmtpSessionLog, but can I get it by reading a property of the ocx? I want to track the message sent for any reply or if the recipient opened the email (smart phone).


Answer

The Message-ID is an email header field, but with one special consideration. The description of the MailMan.AutoGenMessageId in the online reference documentation explains how it's special:

(The AutoGenMessageId property) Controls whether a unique Message-ID header is auto-generated for each email sent.

The Message-ID header field should contain a unique message ID for each email that is sent. The default behavior is to auto-generate this header field at the time the message is sent. This makes it easier for the same email object to be re-used. If the message ID is not unique, the SMTP server may consider the message to be a duplicate of one that has already been sent, and may discard it without sending. This property controls whether message IDs are automatically generated. If auto-generation is turned on (true), the value returned by GetHeaderField("Message-ID") (prior to sending) will not reflect the actual message ID that gets sent with the email. Your application can call GetHeaderField("Message-ID") after sending to get the Message-ID sent in the email.

To turn off automatic Message-ID generation, set this property to false.

You can get the Message-ID of the email after calling SendEmail by getting the "Message-ID" header by calling emailObject.GetHeaderField("Message-ID")