I'm trying to send email with C#. Our email provider suggested that I use mail.example.com/exchange
instead of mail.example.com
string mailServer;
mailServer = "mail.example.com";
mailServer = "mail.example.com/exchange";
SmtpClient smtpClient = new SmtpClient(mailServer);
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Credentials = new NetworkCredential("username", "password");
smtpClient.Send("[email protected]", "[email protected]", "subj", "email body");
When mailServer
does not include a directory, after a long pause, I get:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
When mailServer
does include a directory, with no pause at all, I get:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'mail.example.com/exchange'
How can I send an email with C# for a FQDN that includes a directory?