如何在VB.NET或C#.NET代码中从雅虎邮件ID发送邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/684454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to send mail from yahoo mail Id in VB.NET or C#.NET code
提问by sivakumar
I want to send mail from my yahoomail Id.How to send mail from yahoo mail Id in VB.NET or C#.NET code. Kind help needed.. Advance Thanks.
我想从我的 yahoomail Id 发送邮件。如何在 VB.NET 或 C#.NET 代码中从 yahoo mail Id 发送邮件。需要帮助.. 提前谢谢。
Sivakumar.P
西瓦库玛
采纳答案by Tom Alderman
Here are some examples of doing a basic html email messages.
下面是一些制作基本 html 电子邮件的示例。
http://help.yahoo.com/l/us/yahoo/mail/original/mailplus/pop/pop-14.html
http://help.yahoo.com/l/us/yahoo/mail/original/mailplus/pop/pop-14.html
' VB
Dim m As MailMessage = New MailMessage
m.From = New MailAddress("[email protected]", "Your Name")
m.To.Add(New MailAddress("[email protected]", "Recipient Name"))
m.Subject = "Hello"
' Specify an HTML message body
m.Body = "<html><body><h1>My Message</h1><br>Put the body here.</body></html>"
m.IsBodyHtml = True
' Send the message
Dim client As SmtpClient = New SmtpClient("smtp.mail.yahoo.com")
client.Send(m)
// C#
MailMessage m = new MailMessage();
m.From = new MailAddress("[email protected]", "Your Name");
m.To.Add(new MailAddress("[email protected]", "Recipient Name"));
m.Subject = "Hello";
// Specify an HTML message body
m.Body = "<html><body><h1>My Message</h1><br>Put the body here.</body></html>";
m.IsBodyHtml = true;
// Send the message
SmtpClient client = new SmtpClient("smtp.mail.yahoo.com");
client.Send(m);