+1 vote

How can I get the GmailID and the UID when I send a new email using SMTP?

by
edited by

1 Answer

0 votes
 
Best answer

SMTP protocol doesn't return such data data in any way.

What you can do, is to use IMAP to select "Sent Itmes" folder and find the sent message.

I think the best way to do it, is to remember "Message-ID" header of the message before sending (IMail.MessageID) and using that in a search query.

using(Imap imap = new Imap())
{
    imap.ConnectSSL ("imap.gmail.com");   
    imap.UseBestLogin("user", "password");

    var common = new CommonFolders(imap.GetFolders());
    imap.Select(common.Sent);

    List<long> uids = imap.Search(
        Expression.MessageID(email.MessageID));

Then use GetMessageInfoByUID or GetEnvelopeByUID to retreieve Gmail MessageId (Envelope.GmailMessageId)

by (301k points)
selected by
...