get sent mails via imap

2019-07-16 17:20发布

Does someone know how I can get all sent mails to specific user using AE.NET mail library?

I've tried something like this:

imap = new ImapClient(imapMailServer, username, password, ImapClient.AuthMethods.Login, imapMailPort, imapUseSSL);

if (imap.IsConnected)
{
    imap.SelectMailbox("INBOX");

    var msg = imap.SearchMessages(SearchCondition.To("examplemail@gmail.com"));
}

But without any success (msg collection is empty)...

EDIT (SOLUTION):

I had to select sent folder instead of inbox. Because I am using gmail, Gmail's sent mail folder is named "[Gmail]/Sent Mail". So it has to be:

imap.SelectMailbox("[Gmail]/Sent Mail");

标签: c# email imap
1条回答
Juvenile、少年°
2楼-- · 2019-07-16 17:42

Are you looking for message you've sent? In that case, they're likely in the Sent folder, which is [Gmail]/Sent Mail on Google.

查看更多
登录 后发表回答