I’m having problem sending an attachment via email using smtp client. It sends great on my computer and a friends computer. But 2 other friend computers are having problems sending the file. I thought the problem would be the port as I’ve read elsewhere that some ISP’s block port 25 so I’ve changed the port to 2525, although that does not fix my problem. They get the same error – Error sending message.
Code provided below –
MailMessage message = new MailMessage();
try
{
SmtpClient client = new SmtpClient("smtp.live.com", 2525);
client.EnableSsl = true;
client.Credentials = new NetworkCredential("accoutn@account.com", "abc123");
MailAddress senderAddress = new MailAddress("DoNotReply@live.com");
Attachment attach = new Attachment(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\" + doc.getFirstName() + doc.getSurname() + ".doc");
message.From = senderAddress;
message.Subject = "Physio Information";
message.Attachments.Add(attach);
message.To.Add("sendmessageto@something.com");
message.Body = "Physio Report of " + doc.getFirstName() + " " + doc.getSurname();
client.Send(message);
MessageBox.Show("Information Processed");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
failMail = true;
}
finally
{
message.Dispose();
}
You must use an alternate port designated by the mail providor. I believe live mail uses port 587. Give that a shot.