I am sending email from my ASP.net web application.
The mails are sending successfully with out fail but most of them are going to spam folder.
Please help me to over come spam filter.
My Send Mail code
public void SendMail(string FromAddress, string ToAddress, string Subject, string BodyText)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(FromAddress,"My Name");
mailMsg.To.Add(new MailAddress(ToAddress));
mailMsg.Subject = Subject;
mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
(System.Text.RegularExpressions.Regex.Replace(BodyText, @"<(.|\n)*?>", string.Empty), null, "text/plain");
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, "text/html");
mailMsg.AlternateViews.Add(plainView);
mailMsg.AlternateViews.Add(htmlView);
// Smtp configuration
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.mysite.com";
smtp.Credentials = new System.Net.NetworkCredential(FromAddress, "password");
smtp.EnableSsl = false;
try
{
smtp.Send(mailMsg);
}
catch (Exception ex)
{
throw ex;
}
}
One thing that stands out is that you are never setting the body. I would remove this line:
// Remove the html alternate view
mailMsg.AlternateViews.Add(htmlView);
And try the following (Untested):
// Set the html view to be the default view, leaving the plain text view as the only alternative view
mailMsg.IsBodyHtml = true;
mailMsg.Body = htmlView;
Mails are often marked as spam due to special words in the subject, the sender's domain or the content of the mail or the attaches. So I don't think it has anything to do with the sending mechanism like c# or .NET
来源:https://stackoverflow.com/questions/8079902/c-net-messages-are-going-to-spam-folder