从c#发送的电子邮件附件被检测为病毒,并被删除 [英] Attachment of Email sent from c# is detected as virus and is deleted

查看:176
本文介绍了从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("info9@gmail.com", "********");
            SmtpServer.Port = 587;
            SmtpServer.Host = "smtp.gmail.com";
            SmtpServer.EnableSsl = true;
            mail = new MailMessage();
            String[] addr = TextBox1.Text.Split(',');
            try 
            {
                mail.From = new MailAddress("info9@gmail.com", "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());
            }

推荐答案

好吧,您无法预测每种特定的防病毒软件会变得多么疯狂.一种实用的建议是将所有要添加为附件的文件压缩(仅在可能的情况下),但这并不能真正保证防病毒程序不会删除附件.在电子邮件级别使用的防病毒工具有时会做一些愚蠢的事情,它还取决于应用于特定主机的策略选项.

—SA
Well, you cannot predict how crazy every particular anti-virus could go. One practical advice would be to zip all the files to be added as attachment (only if you can), but this won''t really guarantee that the attachment is not removed by the antivirus. Antivirus tools used at the level of e-mail sometimes do idiotic things, it also depends on policy options applied on a particular host.

—SA


这篇关于从c#发送的电子邮件附件被检测为病毒,并被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆