简体   繁体   English

使用System.Net.Mail从MVC表单通过电子邮件发送结果

[英]Using System.Net.Mail to email results from MVC form

I'm trying to email the results from a form in my MVC application but when I try to add using System.Net.Mail I get the message that Mail isn't found in the namespace of System.Net. 我正在尝试通过MVC应用程序中的表单通过电子邮件发送结果,但是当我尝试using System.Net.Mail添加时,我收到一条消息,指出在System.Net的命名空间中找不到Mail。

I tried looking for the dll to add as a reference, but I cannot find the dlls for System, System.Net or System.Net.Mail. 我试图寻找要添加的dll作为参考,但找不到System,System.Net或System.Net.Mail的dll。 However it has no problem with using System.Net but that doesn't get me access to MailMessage() or SmtpClient . 但是, using System.Net没问题,但这不能使我访问MailMessage()SmtpClient

I'm using Visual Studio 2017 and the latest versions of MVC. 我正在使用Visual Studio 2017和最新版本的MVC。 Does anyone know where to find or how to install these dll's or if there's a better way to email form results I'd love to hear it. 有谁知道在哪里找到或如何安装这些dll,或者是否有更好的方法通过电子邮件发送表单结果,我很乐意听到。

Thanks 谢谢

So the credit for this answer should go to Scotty for his comment above: 因此,此答案应归功于Scotty的上述评论:

System.Net.Mail is not yet ported to .net core version 1.1. System.Net.Mail尚未移植到.net核心版本1.1。 This is discussed here: stackoverflow.com/questions/41583858/… – Scotty May 1 at 4:05 在这里讨论: stackoverflow.com/questions/41583858/…–斯科蒂5月1日4:05

Following that the answer is that System.Net.Mail is not ported into .net core yet but might be making it's way with .net core 2.0. 随之而来的答案是System.Net.Mail尚未移植到.net内核中,但可能会在.net core 2.0中实现。 In the meantime the way to get around this is a nice package called MailKit. 同时,解决此问题的方法是一个名为MailKit的好程序包。 Just install that using the package manager and then look to the Readme for examples of how to use it. 只需使用软件包管理器进行安装,然后查看自述文件以获取有关如何使用它的示例。

Thanks again and a shout out to @Scotty 再次感谢,并向@Scotty大喊大叫

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM