.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to send an Email from my domain address in C#, but I get this error
This is my code:
var smtp = new SmtpClient
{
Host = "webmail.myDomain.gov.sa",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("******@myDomain.gov.as", "12345678")
};
var smtp = new SmtpClient
{
Host = "webmail.myDomain.gov.sa",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("******@myDomain.gov.as", "12345678")
};
var mess = new MailMessage(senderAddress, receiverAddress)
{
Subject = message.Subject,
Body = message.Body,
IsBodyHtml = true
};
if (isAttach)
{
mess.Attachments.Add(new Attachment(message.Attachment));
}
smtp.Send(mess);
But I get this error:
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 91.195.89.155:25
Most like the connection information is wrong. Port 25 is seldom used anymore.
note: SmtpClient does not support oauth authentication which is becoming standard.