如何避免收到垃圾邮件

时间:2014-12-29 09:36:51

标签: asp.net email webmail

我已经在asp.net中开发了一个web应用程序,我需要发送通信的电子邮件,这将在几天内正常工作。现在有一天我的所有电子邮件都进入了垃圾邮件文件夹。

我使用以下代码发送邮件

public  void SendMailMessage(string to, string subject, string body, AlternateView Altv, string bcc="")
        {
            // Instantiate a new instance of MailMessage
            MailMessage mMailMessage = new MailMessage();

            // Set the sender address of the mail message
            mMailMessage.From = new MailAddress("FORM EMAIL");
            // Set the recepient address of the mail message

            mMailMessage.To.Add(new MailAddress(to));

            mMailMessage.Subject = subject;
            // Set the body of the mail message

            if (bcc != "")
            {
                mMailMessage.Bcc.Add(bcc);
            }

            mMailMessage.AlternateViews.Add(Altv);

            mMailMessage.Body = body;

            // Set the format of the mail message body as HTML
            mMailMessage.IsBodyHtml = true;
            // Set the priority of the mail message to normal
            mMailMessage.Priority = MailPriority.Normal;



            // Instantiate a new instance of SmtpClient
            SmtpClient mSmtpClient = new SmtpClient();

            mSmtpClient.Host = "HOST";
            // Send the mail message

            mSmtpClient.Credentials = new System.Net.NetworkCredential()
            {
                UserName = "EMAIID",
                Password = "PASSWORD"

            };
            mSmtpClient.Port = 25;
            mSmtpClient.EnableSsl = true;
            mSmtpClient.UseDefaultCredentials = true;  
            try
            {
                mSmtpClient.Send(mMailMessage);
            }
            catch
            {}

        }

我想将已签名,回复,取消订阅添加到电子邮件标题中,以便将电子邮件发送到收件箱以及如何

1 个答案:

答案 0 :(得分:0)

添加到您的代码:

        mMailMessage.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");

请参阅:Avoiding Spam

相关问题