I have a .Net application. I want this application to send an email to me. How do I implement this without installing an SMTP server?
我有一个.Net应用程序。我希望此应用程序向我发送电子邮件。如何在不安装SMTP服务器的情况下实现此目的?
3 个解决方案
#1
15
Using an SmtpClient
to send a MailMessage
does not require you to have a server on your local machine.
使用SmtpClient发送MailMessage不需要您在本地计算机上安装服务器。
Your e-mail service provider is the one with the server (e.g. smtp.gmail.com), and your SmtpClient
talks to it.
您的电子邮件服务提供商是服务器(例如smtp.gmail.com),您的SmtpClient与之通信。
#2
9
This article by Peter Bromberg on eggheadcafe.com
这篇文章由Peter Bromberg在eggheadcafe.com上发表
C# SMTP Mail without SMTP Service or CDO
没有SMTP服务或CDO的C#SMTP邮件
explains how to send email without relying on an SMTP client:
解释了如何在不依赖SMTP客户端的情况下发送电子邮件:
Sending email via TCP using the native SMTP RFC commands "HELO", "MAIL From", RCPT TO", etc. is no big deal. That's one of the first tricks we learn with Telnet. Finding or writing managed code that will do so reliably is another story. The code in the class that follows is not my original code - I've cobbled it together from three different sample sources, fixing namespaces, error handling, and other minor items, changing console code to class library code, and providing a complete Winforms - based test harness front end that illustrates its correct usage.
使用本机SMTP RFC命令“HELO”,“MAIL From”,“RCPT TO”等等通过TCP发送电子邮件并不是什么大问题。这是我们用Telnet学习的第一个技巧之一。查找或编写将执行此操作的托管代码可靠的是另一个故事。下面的类中的代码不是我的原始代码 - 我从三个不同的示例源拼凑它,修复名称空间,错误处理和其他次要项目,将控制台代码更改为类库代码,以及提供完整的基于Winforms的测试线束前端,说明其正确用法。
I've also included sample code to correctly process and add a mail attachment via an OpenFileDialog here. This code MIME encodes and transmits the attachment(s) according to the specification.
我还提供了示例代码,以通过OpenFileDialog正确处理和添加邮件附件。此代码MIME根据规范对附件进行编码和传输。
#3
3
You can't send email without the services of a SMTP server, there is of course no need for you to install one, just point your code at your ISPs SMTP server or your companies Exchange server (or what ever they use).
如果没有SMTP服务器的服务,您无法发送电子邮件,当然不需要安装电子邮件,只需将代码指向ISP的SMTP服务器或公司的Exchange服务器(或者他们使用的服务器)。
#1
15
Using an SmtpClient
to send a MailMessage
does not require you to have a server on your local machine.
使用SmtpClient发送MailMessage不需要您在本地计算机上安装服务器。
Your e-mail service provider is the one with the server (e.g. smtp.gmail.com), and your SmtpClient
talks to it.
您的电子邮件服务提供商是服务器(例如smtp.gmail.com),您的SmtpClient与之通信。
#2
9
This article by Peter Bromberg on eggheadcafe.com
这篇文章由Peter Bromberg在eggheadcafe.com上发表
C# SMTP Mail without SMTP Service or CDO
没有SMTP服务或CDO的C#SMTP邮件
explains how to send email without relying on an SMTP client:
解释了如何在不依赖SMTP客户端的情况下发送电子邮件:
Sending email via TCP using the native SMTP RFC commands "HELO", "MAIL From", RCPT TO", etc. is no big deal. That's one of the first tricks we learn with Telnet. Finding or writing managed code that will do so reliably is another story. The code in the class that follows is not my original code - I've cobbled it together from three different sample sources, fixing namespaces, error handling, and other minor items, changing console code to class library code, and providing a complete Winforms - based test harness front end that illustrates its correct usage.
使用本机SMTP RFC命令“HELO”,“MAIL From”,“RCPT TO”等等通过TCP发送电子邮件并不是什么大问题。这是我们用Telnet学习的第一个技巧之一。查找或编写将执行此操作的托管代码可靠的是另一个故事。下面的类中的代码不是我的原始代码 - 我从三个不同的示例源拼凑它,修复名称空间,错误处理和其他次要项目,将控制台代码更改为类库代码,以及提供完整的基于Winforms的测试线束前端,说明其正确用法。
I've also included sample code to correctly process and add a mail attachment via an OpenFileDialog here. This code MIME encodes and transmits the attachment(s) according to the specification.
我还提供了示例代码,以通过OpenFileDialog正确处理和添加邮件附件。此代码MIME根据规范对附件进行编码和传输。
#3
3
You can't send email without the services of a SMTP server, there is of course no need for you to install one, just point your code at your ISPs SMTP server or your companies Exchange server (or what ever they use).
如果没有SMTP服务器的服务,您无法发送电子邮件,当然不需要安装电子邮件,只需将代码指向ISP的SMTP服务器或公司的Exchange服务器(或者他们使用的服务器)。