我创建一个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