我創建一個CSV文件,並將其連接到像這樣的電子郵件...c#如何將附件保存到文件夾? .NET2
using (MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(csv)))
{
try
{
to = "[email protected]";
string from = "[email protected]";
string subject = "Order p"+ OrderNumber;
string body = result;
SmtpClient SMTPServer = new SmtpClient("127.0.0.1");
MailMessage mailObj = new MailMessage(from, to, subject, body);
Attachment attachment = new Attachment(stream, new ContentType("text/csv"));
attachment.Name = "p" + OrderNo + "_" + CustomerReference+".csv";
mailObj.Attachments.Add(attachment);
SMTPServer.Send(mailObj);
}
catch (Exception ex)
{ }
}
這工作得很好,但如何我同csv文件保存到一個文件夾?謝謝
剛剛編輯我的答案,祝你好運。 – Ademar