【发布时间】:2015-03-27 16:29:51
【问题描述】:
我正在尝试使用以下代码 sn-p 发送电子邮件。
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("cs@abc.com");
mailMsg.Subject = "Test";
mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
mailMsg.To.Add("abc.test@gmail.com");
// Set the body of the mail message
var BodyText = "<html><body>Hi..</body></html>";
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 = "mail.shopmanza.com";
smtp.Credentials = new NetworkCredential("cs@abc.com", "Cs@abc");
smtp.Send(mailMsg);
我的邮件进入垃圾邮件文件夹而不是收件箱。知道如何解决这个问题吗?
【问题讨论】:
-
您的邮件客户端认为它是垃圾邮件的动机,更改垃圾邮件过滤规则或邮件正文/来自。恕我直言,它与您的代码无关 per si
-
嗨,让,感谢您的回复。我将这封邮件发送给我的许多可能使用 gmail 的网站客户。我如何确保这封邮件不会进入他们的垃圾邮件文件夹?
-
你能试试没有来自真实地址的链接的纯文本电子邮件吗?在阅读 gmail 文档之前:support.google.com/mail/answer/1366858?hl=en