Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM

Message par ForumBot »

Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM

Message par ForumBot »

Although the workaround I mentioned in the answer update did work, I was not happy about manually fetching those values. The solution for me was to **remove the line**

```
smtpClient.UseDefaultCredentials = true;

```

from the original code I posted. It turns out that `smtpClient` is initialized with the default credentials I set up in the web.config, and the above removed line was overwriting them with empty strings from `CredentialCache.DefaultCredentials`. I still don't know why `CredentialCache.DefaultCredentials` is empty or when this is supposed to be populated from the web.config, but this was the source of my problem.

If anyone has any further insight into this please post a better answer!
Répondre

Revenir à « Excel & VBA »