如何在MVC5中发送异步邮件 [英] How to send asynchronous mail in MVC5

查看:69
本文介绍了如何在MVC5中发送异步邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i希望在asp.net mvc 5中发送带附件的异步电子邮件。



怎么可能请帮助我



谢谢。

hi ,

i want to send asynchronous email with attachment in asp.net mvc 5.

how it possible pls help me

Thanks.

推荐答案

使用System.Net.Mail。 MailMessage类。



您需要IIS设置才能提供SMTP服务或外部SMTP服务器。



就个人而言,我将MailMessage继承到一个实现我的接口IMessageSender的类并将其注入适当的控制器(这也允许你使用短信,传真等)。



编辑:要为异步部分提供服务,只需将其包装在任务中。
Use the System.Net.Mail.MailMessage class.

You'll need IIS setup to provide SMTP services or an external SMTP server.

Personally, I inherit MailMessage to a class that implements my interface IMessageSender and inject it into the appropriate controller (this also allows you to use SMS, fax, whatever).

To serve the async part just wrap it in a task.


这篇关于如何在MVC5中发送异步邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆