What is the best way to send a HTML email from Asp.net MVC?

后端 未结 5 1127
Happy的楠姐
Happy的楠姐 2021-01-17 23:53

I would like to be able to render a view and send it as an email, similar to what can be done with Ruby on Rails. What is the best way to do this?

EDIT: My solution

相关标签:
5条回答
  • 2021-01-18 00:31

    Once the post mvc-preview-5-rendering-a-view-to-string-for-testing has an answer with a solution in it, that solution applies to this one as well. Once you have a string, you coud mail it using default .net mail options (as indicated by dimarzionist: SendMail / SmtpClient).

    0 讨论(0)
  • 2021-01-18 00:34

    Sorry mate, but I thing there is something wrong with your understanding of ASP.NET MVC. It's still the part of ASP.NET and framework, so you can use the same techniques you used there like SendMail and SmtpClient.

    0 讨论(0)
  • 2021-01-18 00:40

    You can consider MvcMailer. See the NuGet package here and the project documentation

    Hope it helps!

    0 讨论(0)
  • 2021-01-18 00:47

    This looks like a possible implementation of the approach suggested by Haacked.

    0 讨论(0)
  • 2021-01-18 00:52

    I'd advise Postal

    It allows you to create e-mails using (strongly typed) MVC views, and send them using the standard SmtpClient.

    0 讨论(0)
提交回复
热议问题