1
votes

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?

2

2 Answers

4
votes

SMTP doesn't support the concept of directories, so you might want to get an email provider that knows what they're talking about.

0
votes

That seems more like a webmail address than an SMTP address. DNS isn't going to know what to do with that path. Verify that they are talking about SMTP connections (very likely they have an alternate port they use)