添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi!. I'm currently working on one specific app that should send e-mail via outlook and using mailkit. App is logging in via oauth2 and imap authentication is OK, but not smtp.

I'm getting this exception:

> 535: 5.7.3 Authentication unsuccessful

> [AM6P192CA0023.EURP192.PROD.OUTLOOK.COM]

Code sample:

    var publicClientApplication = PublicClientApplicationBuilder.Create(ClientId)
                        .WithRedirectUri(RedirectUri)
                        .Build();
    var scopes = new string[]
        "email",
        "offline_access",
        "https://outlook.office.com/IMAP.AccessAsUser.All",
        "https://outlook.office.com/SMTP.Send"
    var authToken = await publicClientApplication.AcquireTokenInteractive(scopes).ExecuteAsync();
    SaslMechanism oauth2;
    if (account.ImapClient.AuthenticationMechanisms.Contains("OAUTHBEARER"))
        oauth2 = new SaslMechanismOAuthBearer(authToken.Account.Username, authToken.AccessToken);
        oauth2 = new SaslMechanismOAuth2(authToken.Account.Username, authToken.AccessToken);
    await SmtpClient.ConnectAsync(smtp.office365.com, 587, SecureSocketOptions.StartTls);
    await SmtpClient.AuthenticateAsync(oauth2);

API permissions in app registration:



Any ideas?

Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.

Hi Valentin I'm Anna and I'd be happy to help you with your question. In this Forum, we are Microsoft consumers just like yourself. Sorry for the trouble this might have caused. Please note that this is not my area of expertise but need to respond as the question was left unattended to. Please see this YouTube video and then retrace your steps https://www.youtube.com/watch?v=hOgvTDKKgnY

Note: This is a non-Microsoft website. The page seems to provide accurate and reliable information. Beware of advertisements on the site that may advertise products frequently classified as PUPs (potentially unwanted products). Do thorough research on any product advertised on the site before downloading and installing it. I hope this helps ;-), let me know if this is contrary to what you need, I would still be helpful to answer more of your questions. Best Regards, Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom. Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.