我正在创建一个 csv 文件并将其附加到这样的电子邮件中......
using (MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(csv)))
{
try
{
to = "email@email.com";
string from = "user@email.co.uk";
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 文件保存到文件夹中?谢谢