0 votes

I create an EWS outlook app.

When saving an email i need to use the mail.dll to access the mail item.

is there a sample how to go about that? i only have the token from the EWS outlook app and not the user name.

how can i access a mail item using a token an a mail item id?


by (300 points)
Do you have a raw eml version of the message?
this is how it is done by Microsoft:

 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
                Url = new Uri(value.outlookTokenInfo.ewsUrl),
                Credentials =  new OAuthCredentials(value.outlookTokenInfo.token)

and than:

 Item item = Item.Bind(service, value.outlookTokenInfo.item);

as you can see to get an email item the authentication is done using a token and mail item id.

is there a similar way to do the same using mail.dll?

1 Answer

0 votes

Mail.dll support OAuth 2.0:

Scenario for installed applications:

Scenario for web applications:

For Office365 / Exchange Online, consider reading this articles:



Basically if you have an access token, the code is very simple:

string accessToken = ...;
using (Imap imap = new Imap())
    imap.LoginOAUTH2(user, accessToken);

    List<long> uids = imap.Search(Flag.Unseen);

    foreach (long uid in uids)
        var eml = imap.GetMessageByUID(uid);
        IMail email = new MailBuilder().CreateFromEml(eml);
by (298k points)
edited by