0 votes

My 1st question is do you support async / await paradigm?

When I try to use the await method on Pop3.Connect that is awaitable I get a compile time error,

When I try to use Login I get an error: "please connect first" what am I doing wrong.

Also in you example you use UseBestLogin, unfortunately this does not exist in MailForWindowsStore.dll.


1 Answer

0 votes
Best answer

In MailForWindowsStore.dll all methods have async counterparts. Please use:

await pop3.Connect("imap.example.com");


await pop3.ConnectSSL("imap.example.com");

before invoking UseBestLoginAsync. UseBestLoginAsync exists in MailForWindowsStore.dll. There is only async version of this method:

await imap.UseBestLoginAsync("user@example.com", "password");

Here's a full POP3 sample for Windows Store Apps:

using(Pop3 pop3 = new Pop3())
    await pop3.Connect("pop3.server.com");  // or ConnectSSL   
    await pop3.UseBestLoginAsync("user", "password");

    List<string> uids = await pop3.GetAllAsync();
    foreach (string uid in uids)
        IMail email = new MailBuilder()
            .CreateFromEml(await pop3.GetMessageByUIDAsync(uid));

        string subject = email.Subject;
        var attachments = email.Attachments;
    await pop3.CloseAsync();
by (288k points)