如何使用C#.net发送电子邮件 [英] how to send email using C#.net
本文介绍了如何使用C#.net发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用c#.net中的Windows应用程序发送电子邮件?
How to send email using windows application in c#.net?
推荐答案
创建一个MailMessage和一个SmtpClient并发送它。
Create a MailMessage and a SmtpClient and send it.
MailMessage msg = new MailMessage();
msg.From = new MailAddress("from@gmail.com", "Display name");
msg.Subject = "Hello mail!";
msg.Body ="This is my email";
// Set more properties if you like.
SmtpClient client = new SmtpClient();
// Set client properties. Authentication, smtp server etc. or use app.config (see below)
client.Send(msg);
你可以在app.config文件中配置你的smtp-client。
You could configure you''re smtp-client in app.config file.
<system.net>
<mailsettings>
<smtp from="from@gmail.com">
<network host="smtp.mail.com" port="587" username="from@mail.com" password="***" />
</smtp>
</mailsettings>
</system.net>
尝试一些初步研究,您可以采取多种方法,具体取决于您的背景电子邮件系统。
http://bit.ly/11gXx2Z [ ^ ]
Try some initial research, there are various approaches you can take depending on the context of your e-mail system.
http://bit.ly/11gXx2Z[^]
这篇关于如何使用C#.net发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文