我創建使用字符串生成一個HTML並把它放在當前目錄一個文件附加到一條消息
StreamWriter sw = new StreamWriter("../../Data.html");
現在我想附上這個文件,並把它作爲一個郵件。我怎樣才能將此作爲附件添加到我的電子郵件中?
這是我多少用常規的html消息做的事情。我如何將文件作爲附件添加到它?
public bool sendMailAttachment(string to, string from, string subject, string body, string attachment)
{
bool k = false;
try
{
SmtpClient client;
MailMessage msg = new MailMessage(from, to);
msg.Subject = subject;
msg.Body = body;
msg.IsBodyHtml = true;
client = new SmtpClient();
client.Host = "staging.itmaniax.co.za";
//client.Port = 25;
//****
//client.EnableSsl = true;
client.Send(msg);
k = true;
}
catch (Exception exe)
{
Console.WriteLine(exe.ToString());
}
return k;
有MAILMESSAGE的對象上的附件屬性.... –
創造新的問題之前,請回頭看看你以前的問題,接受任何適合你的答案......例如,你昨天問了一個非常類似的問題,回答如下:http://stackoverflow.com/questions/14357877/trying-to-send-a-basic-email- to-folder – Arran