0 votes

Am not able to fetch data from different folders like sent mail, drafts, trash etc.

Code:

Imap imaplog = new Imap();
imaplog.ConnectSSL(hostAddrs, portAddrs);
imaplog.UseBestLogin(userID, Pwd);

CommonFolders common = new CommonFolders(imaplog.GetFolders());
imaplog.Select(common.Sent);

long uid;
List<long> uids;
uids = imaplog.Search(Flag.Recent);
uids.Reverse();
uids = uids.Take(5).ToList();

mailSent = new string[uids.Count][];

for (int i = 0; i < uids.Count; i++)
{
    uid = uids[i];
    var eml = imaplog.GetMessageByUID(uid);
    imaplog.MarkMessageSeenByUID(uid);
    IMail email = new MailBuilder().CreateFromEml(eml);
    mailSent[i] = new string[4] 
    { 
        email.Text, 
        email.Subject, 
        email.To.ToString(), 
        email.Date.ToString() 
    };
}
imaplog.Close();
by
Could you please be more specific, what is your problem exactly?
When i run this code , i am not getting neither getting any error nor any data from the server even if mails are present in sent box of gmail.
Don't Imap.Search(Flag.Recent) use Imap.GetAll().

1 Answer

0 votes
 
Best answer

Use:

uids = imaplog.GetAll();

instead of:

uids = imaplog.Search(Flag.Recent);
by (300k points)
edited by
...