本文介绍了从c#发送的电子邮件附件被检测为病毒,并被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我正在使用代码(可在此Web上找到)通过电子邮件自动从应用程序向客户端发送报告,但是客户端的防病毒软件正在检测附件(PDF格式的报告)为病毒并将其删除.任何人都可以帮助我如何在不停止客户端防病毒的情况下防止t.
Hi everyone, I''m sending reports via Email automatically from application to clients using code (found on this web) but antivirus of client is detecting attachment (Report in PDF) as virus and is deleting it. could anybody help me how to prevent t without stopping client antivirus.
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new
System.Net.NetworkCredential("[email protected]", "********");
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.gmail.com";
SmtpServer.EnableSsl = true;
mail = new MailMessage();
String[] addr = TextBox1.Text.Split(',');
try
{
mail.From = new MailAddress("[email protected]", "So and So", System.Text.Encoding.UTF8);
Byte i;
for( i = 0;i< addr.Length; i++)
mail.To.Add(addr[i]);
mail.Subject = TextBox3.Text;
mail.Body = TextBox4.Text;
if(ListBox1.Items.Count != 0)
{
for(i = 0;i<ListBox1.Items.Count;i++)
mail.Attachments.Add(new Attachment(ListBox1.Items[i].ToString()));
}
LinkedResource logo = new LinkedResource(path);
logo.ContentId = "Logo";
string htmlview;
htmlview = "<html><body><table border=2><tr width=100%><td><img src=cid:Logo alt=companyname /></td><td>MY COMPANY DESCRIPTION</td></tr></table><hr/></body></html>";
AlternateView alternateView1 = AlternateView.CreateAlternateViewFromString(htmlview + TextBox4.Text, null, MediaTypeNames.Text.Html);
alternateView1.LinkedResources.Add(logo);
mail.AlternateViews.Add(alternateView1);
mail.IsBodyHtml = true;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
mail.ReplyTo = new MailAddress(TextBox1.Text);
SmtpServer.Send(mail);
}
catch (Exception ex){
MessageBox.Show(ex.ToString());
}
推荐答案
这篇关于从c#发送的电子邮件附件被检测为病毒,并被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!