Senden Sie E-Mails mit OAuth und Miscrosft Personal EmailC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Senden Sie E-Mails mit OAuth und Miscrosft Personal Email

Post by Anonymous »

Ich versuche, E-Mails über die Chilkat-SMTP-Bibliothek mit einem persönlichen Microsoft-Konto und oAuth zu senden.
hier ist der Teil des Codes, den ich verwende:

Code: Select all

//preparing Mail Object
Chilkat.MailMan mail = new Chilkat.MailMan()
{
SmtpHost = "smtp.office365.com",
SmtpPort = 587,
StartTLS = true,
SmtpUsername = sysConfig.Client.Email,
OAuth2AccessToken = token,
};

//opening smtp connection
bool bPass = mail.SmtpConnect();
if(bPass == false)
{
return false;
}

//authenticate smtp
bPass = mail.SmtpAuthenticate(); //it's fails here
if(bPass == false)
{
return false;
}
Hier ist die Fehlermeldung, die ich erhalte:

Code: Select all

535 5.7.3 Authentication unsuccessful [SI2P153CA0005.APCP153.PROD.OUTLOOK.COM 2025-12-04T14:15:45.148Z 08DE31ECD6048A52]
Ich dachte also, dass mein Zugriffs-/Aktualisierungstoken möglicherweise abgelaufen ist, also habe ich mein Konto erneut autorisiert

Code: Select all

Your code is correct for OAuth2, but Outlook/Hotmail SMTP (smtp.office365.com) NO LONGER accepts OAuth2 tokens for personal Hotmail/Outlook.com accounts.
Dies ist der Beweis für die ChatGpt-Antwort
Chat-GPT-Antwort über MS oAuth
Ich mache mir Sorgen, und bei einem zweiten Gedanken fragte ich Google Gemini, und er sagte (der Kern):

Code: Select all

It is not true that Microsoft personal accounts (e.g., Outlook.com, Hotmail.com) do not support SMTP OAuth. In fact, Microsoft is phasing out basic authentication (username and password) for security reasons and requires the use of OAuth 2.0 (Modern Authentication) for applications connecting via SMTP
Jetzt schwirrt mir der Kopf ... und ich bin verwirrt, wer Recht und wer Unrecht hat?
Und wenn das hilft, mein Zugriffstoken als Zugriff auf folgende Bereiche:

Code: Select all

"openid",
"profile",
"User.Read",
"email",
"offline_access",
"Mail.ReadWrite",
"Mail.Send",
"SMTP.Send",
"MailboxSettings.ReadWrite",
"Files.ReadWrite",
Irgendeine Hilfe, um die Sache hier richtig zu machen? (Den Code zum Laufen bringen?)
Mit freundlichen Grüßen

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post