7

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

Arnold
  • 515
  • 1
  • 9
  • 18

1 Answers1

9

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.

Robin van der Knaap
  • 4,060
  • 2
  • 33
  • 48
  • +1 as they have some great docs (especially the unit testing part) – Adam Tuliper Sep 22 '11 at 23:06
  • I just stumbled upon MvcMailer, and WOW...that stuff should have been baked into MVC3, instead of the crappy WebMail helper methods that just recreate SmtpClient as a static class. Kudos for MvcMailer! +1 for this recommendation. – Thiago Silva Feb 14 '12 at 16:03