Stream as an Attachment to System.Net.Mail is 0 bytes

后端 未结 2 1095
温柔的废话
温柔的废话 2021-02-02 13:54

I\'ve got a project where I\'m using a PDF generator to send a file to a user. We\'d like to give the user the option to attach this file to an email instead, and we\'re having

2条回答
  •  有刺的猬
    2021-02-02 14:56

    A guess... Back dat stream up to the beginning before sending nit

    // Set the position to the beginning of the stream.
    stream.Seek(0, SeekOrigin.Begin);
    mail.Attachments.Add(new Attachment(stream, "myPdf.pdf"));
    mail.Send();
    

提交回复
热议问题