Hi ,
I have to send mail using private server. But i receive " Failure sending mail. " error
My code
private static void SendMail()
{
try
{
string SmtpHost = ConfigurationManager.AppSettings["SmtpHost"].ToString();
string SmtpFromMail = ConfigurationManager.AppSettings["SmtpFromMail"].ToString();
string SmtpFromMailPwd = ConfigurationManager.AppSettings["SmtpFromMailPwd"].ToString();
//foreach (DataRow dr in objDataTable.Rows)
//{
MailMessage mail = new MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress(SmtpFromMail);
//string EventName = DicEventTypeName[dr["Email"].ToString()];
mail.Subject = "Testing";
mail.Body = "Test";
SmtpClient smtp = new SmtpClient();
smtp.Host = SmtpHost; //Or Your SMTP Server Address
smtp.Port = 25;
smtp.Credentials = new System.Net.NetworkCredential(SmtpFromMail, SmtpFromMailPwd); //
smtp.EnableSsl = true;
smtp.Send(mail);
}catch(Exception e)
{
}
}
Could you give any suggestion ?
Thanks in advance !!
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Sreekanth ReddyPosted Nov 13, 2018, 3:22 AM
Madan ShekarPosted Nov 13, 2018, 4:25 AM
https://sendgrid.com/docs/for-developers/sending-email/v3-csharp-code-example/
Create account and generate api key start to use
code starts form here , any doubt ping me
}Amit GuptaPosted Nov 13, 2018, 3:50 AM