C# 发送带有附件C的电子邮件#
可能重复:C# 发送带有附件C的电子邮件#,c#,smtp,C#,Smtp,可能重复: 这是我的剧本: 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 = "Bod
这是我的剧本:
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);
}
它工作得很好,但我还没有想出一个方法来添加附件。是的,我知道这个网站有一些例子,但我找不到一个可以发送附件的。使用。那是脚本?在我看来,它就像一个电脑程序。试试谷歌搜索“发送附件”。第一组结果应该给你你想要的。-1绝对没有研究工作:->第一个链接: