Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send email asynchronously from a MVC 3 application?

In my MVC 3 Razor application, an ActionResult Create() method in the Controller handles a user HttpPost. At that point:

  1. Data is saved to a database.
  2. Emails are sent to interested parties using another project in the solution.
  3. A Confirmation page is served back to the user.

Since emailing is the most time-consuming activity, I'm attempting to use SmtpClient.SendAsync(), rather than SmtpClient().Send.

Is this scenario possible if inheritance is from AsyncController? Can anyone provide an example?

Thanks,

Arnold

like image 1000
Arnold Avatar asked Sep 22 '11 22:09

Arnold


1 Answers

You should definitely check out MVC Mailer. Very nice tool to create emails with razor views. It has an option to send mails asynchronously. MVC mailer is also available via nuget.

like image 152
Robin van der Knaap Avatar answered Oct 05 '22 23:10

Robin van der Knaap