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

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

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

Message par Clippy »

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

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

Message par Clippy »

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 »