-3

可能重复:
从 WinForms 应用程序发送带有附件的电子邮件?

这是我的脚本:

     var fromAddress = new MailAddress("myemail@gmail.com");
     var toAddress = new MailAddress("myemail@gmail.com");
     const string fromPassword = "mypassword";
     const string subject = "Subject";
     const string body = "Body";

       var smtp = new SmtpClient
       {
           Host = "smtp.gmail.com",
           Port = 587,
           EnableSsl = true,
           DeliveryMethod = SmtpDeliveryMethod.Network,
           UseDefaultCredentials = false,
           Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
       };
       using (var message = new MailMessage(fromAddress, toAddress)
                 {
                     Subject = subject,
                     Body = body,
                 })

       {
           smtp.Send(message);
       }

它运作良好,但我还没有想出一种添加附件的方法。是的,我知道这个网站有示例,但我找不到可以发送附件的示例

4

1 回答 1

1

使用附件属性

于 2012-12-11T02:10:13.373 回答