在C# winform中,我想把c:\a.exe这个文件作为附件发送到 [email protected],怎么实现?谢谢

解决方案 »

  1.   

    exe文件会被反病毒软件屏蔽把
      

  2.   

    exe文件會被屏閉掉的。你需要改成Txt等類型的文件才能偉輸的。
      

  3.   

    using System.Web.Mail;设置SmtpMail.SmtpServer,from,to,subject等等
    把附件路径添好。。或者提前把路径写道list中public void AddAttachments(ArrayList attachmentsList)
    {
    string filePath = string.Empty; foreach (object file in attachmentsList)
    {
    try
    {
    filePath = (string)file;
    if( File.Exists(filePath) == false)
    {
    MessageBox.Show("附件文件不存在或已经被移除,请检查。");
    }
    else
    {//file existed
    MailAttachment MyAttachment = new MailAttachment(filePath);
    msg.Attachments.Add(MyAttachment);
    }
    }
    catch(Exception ex)
    {
    MessageBox.Show("附件文件路径格式错误,请检查。");
    }
    }
    }
      

  4.   

    打包成rar或zip文件后再附加。