The setup: I've got an email-service with an API. My other applications connects to the api, providing an Email-object. The email-service then sends the email. I've got it in a few applications and it works flawless.
Now I'm implementing it into an older desktop application. Problem:
I'm trying to send an email from office365. This works 50% of the times. The other 50% i get an SMTP-exception saying the following: "The remote name could not be resolved: 'smtp.outlook.office365.com' GeneralFailure".
I've tried using smtp.office365.com as remove server too, it still fails every now and then.
The application connects correctly to the API and I get as far as to sending the email. And pretty often, the exception above occurs.
SmtpClient SmtpServer = new SmtpClient(creds.SmtpServer);
SmtpServer.UseDefaultCredentials = false;
SmtpServer.Port = (int)creds.SmtpPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(creds.Account, creds.Password);
SmtpServer.EnableSsl = true;
using (SmtpServer)
{
SmtpServer.Send(mail);
dbLayer.LoggEmail(email, false, null);
return true;
}
Is there anyone with any ideas, thoughts or answers? Its weird it works SOMETIMES.
I've seen this before, basically it's name resolution.
2 common problems:
a)Your machine not being able to correctly connect to the DNS sever or b)DNS server is slow/non-responding.
hth, Dave
telnet smtp.office365.com over port 25 from your local application server. It should succeed with a banner. If not then get the port 25 unblocked on firewall/network. Try then, it should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.