1

我正在创建一个用于在 C# 中发送自动邮件的应用程序。

此邮件包含嵌入图像,我能够生成自动邮件,但它总是进入收件人的垃圾文件夹。

但是,如果我不使用图像,那么它会完美地进入收件箱。请帮忙。下面是代码:

i = 4;
da.SelectCommand = new SqlCommand("Aniversary_cal", conn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@flag", i);
DataTable dt = new DataTable();
da.Fill(dt);

for (int j = 0; j < dt.Rows.Count; j++)
{
    string txt = dt.Rows[j]["Mailid"].ToString();
    txt = txt.Replace(" ", "") + "@xyz.com";
    MailAddress To = new MailAddress(txt);
    MailAddress From = new MailAddress("Congratulations@xyz.com", "Congratulations");
    MailMessage msg = new MailMessage(From, To);
    msg.Subject = "Congratulations on your " + i + "th Anniversary";
    string cc = dt.Rows[j]["Managermailid"].ToString();
    cc = cc.Replace(" ", "") + "@xyz.com";
    msg.CC.Add(cc);


    LinkedResource logo = new LinkedResource("header10yr.jpg");
    logo.ContentId = "companylogo";

    LinkedResource logo1 = new LinkedResource("Footer10yr.jpg");
    logo1.ContentId = "display";

    AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns:st1='urn:schemas-microsoft-com:office:smarttags' xmlns='http://www.w3.org/TR/REC-html40' xmlns:ns0='http://schemas.microsoft.com/office/2004/12/omml'> <head> <meta http-equiv=Content-Type content='text/html; charset=us-ascii'> <meta name=ProgId content=Word.Document> <meta name=Generator content='Microsoft Word 11'> <meta name=Originator content='Microsoft Word 11'> <link rel=File-List href='Document7_files/filelist.xml'> <link rel=Edit-Time-Data href='Document7_files/editdata.mso'> </head><body> <center style=font-family:Times New Roman; font-size:larger><br /><br /> <table style=width:750;font-style:italic;background-color:rgb(188,67,91); border:1px solid #000><tr><td><img src='cid:companylogo' runat=server  width=750 height=150 style=margin-bottom:-7px; border:1px solid #000 /></td></tr><tr><td><span style=text-align:left>Dear " + dt.Rows[j]["Ename"] + "</span></td></tr><tr><td><br><span><center> Hearty congratulations on completion of 4 Years with Infosys. </center></span></td></tr><tr><td><br><span><center>This certainly is a memorable day for us and we are indeed delighted about this occasion. We would like to <br>  express our sincere appreciation for your continued support and contribution, <br />through these cherished years.</center></span> </td></tr><tr><td><span style=text-align:left>Regards</span><br /><span style=text-align:left>Team- HR</span></td></tr><tr><td><img src=cid:display  runat=server width=750 height=120 style=margin-bottom:-4px; border:1px solid #000 /></td></tr></table>Note:This is a System generated Mail.Please do not reply.</center></body></html>", null, System.Net.Mime.MediaTypeNames.Text.Html);
    av1.LinkedResources.Add(logo);
    av1.LinkedResources.Add(logo1);
    msg.AlternateViews.Add(av1);

    msg.IsBodyHtml = true;

    SmtpClient smtp = new SmtpClient("ip address", 25);
    smtp.Send(msg);
4

1 回答 1

0

我认为您超出了 SCL 限制,因此被标记为垃圾邮件。

以下是有关 SCL 的一些信息,尽管这是针对特定版本的,但相同的原则适用于大多数垃圾邮件过滤。

于 2012-09-14T09:20:26.957 回答