-3
可能重複:
Send email with attachment from WinForms app?發送電子郵件附件C#
這裏是我的腳本:
var fromAddress = new MailAddress("[email protected]");
var toAddress = new MailAddress("[email protected]");
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);
}
它運作良好,但我還沒有想出一種添加附件的方式。是的,我知道這個網站有例子,但我不能找到一個會發送附件
這是一個腳本?它對我來說就像一個電腦程序。 –
嘗試使用「c#發送附件」進行Google搜索。第一組結果應該給你你想要的。 – tsells
-1完全沒有研究工作:http://www.google.com.au/search?q=send+email+attachment+stackoverflow+c%23 - >第一個鏈接:http://stackoverflow.com/questions/ 2204698 /發送電子郵件與 - 附件 - 從 - 的WinForms應用程序內 –