+1 vote

Hello,
I want to store the id of the email that i sent to database. Later I want to get it via this id. Is this possible?
Thank you.

by
retagged by

1 Answer

0 votes

You have basically two ways of doing that:

  1. Store IMail.MessageId. It is assigned by the sender, Mail.dll generates that automatically for each email, but you can set it yourself if you want.
  2. or store IMAP's UID.

Now few points:

  • SMTP protocol doesn't return the any kind of id of the send message.

  • Some SMTP servers store sent mail on the IMAP server in 'sent mail' folder automatically, others don't. Unfortunately there is no way to check that programmatically. So in some cases you'll need to upload mail you sent to IMAP's 'sent mail' yourself.

  • When you upload email yourself, most server will return an UID assigned to this email message (it is returned by Imap.UploadMessage method). Unfortunately some server don't do that - in that case you'll have to remember IMail.MessageID of the email you created, and perform a search based on that in the 'sent mail' folder (Imap.Search).

  • If the SMTP server puts emails to 'sent mail' automatically, you'll also need to perform a search based on IMail.MessageID property.

Here's a good read on unique ids in IMAP.
Here's a good read on searching in IMAP.

by (301k points)
...