Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM
Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM
Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM
Re: Exception using default SMTP credentials on Office365 - Client was not authenticated to send anonymous mail during MAIL FROM
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!
```
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!