How to send an email with attachments using SmtpClient.SendAsync?

前端 未结 3 519
眼角桃花
眼角桃花 2020-12-02 16:00

I am using a service component through ASP.NET MVC. I would like to send the email in a asynchronous way to let the user do other stuff without having to wait for the sendin

3条回答
  •  一生所求
    2020-12-02 16:23

    Don't use "using" here. You are destroying the memory stream immediately after calling SendAsync, e.g. probably before SMTP gets to read it (since it's async). Destroy your stream in the callback.

提交回复
热议问题