Sending mail with attachments programmatically in ASP.NET

后端 未结 4 1793
轮回少年
轮回少年 2021-02-03 13:13

I am dynamically generating a number of different types of files based upon a GridView in ASP.NET - an Excel spreadsheet and a HTML file. I am doing so using this code (this is

4条回答
  •  独厮守ぢ
    2021-02-03 13:34

    You might be able to create System.Net.Mail.Attachment from string then send out the mail as normal.

    var m = new System.Net.Mail.MailMessage(from, to, subject, body);
    var a = System.Net.Mail.Attachment.CreateAttachmentFromString(stringWrite.ToString(), "application/vnd.xls");
    m.Attachments.Add(a);
    

提交回复
热议问题