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

前端 未结 3 518
眼角桃花
眼角桃花 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:26

    I have tried your function and it works even for email with in memory attachments. But here are some remarks:

    • What type of attachments did you try to send ? Exe ?
    • Are both sender and receiver on the same email server ?
    • You should “catch” exception and not just swallow it, than you will get more info about your problem.
    • What does the exception says ?

    • Does it work whan you use Send instead of SendAsync ? You are using 'using' clause and closing Stream before email is sent.

    Here is good text about this topic:

    Sending Mail in .NET 2.0

提交回复
热议问题