正在向Gmail帐户发送消息... [英] Sending a message to gmail account ...
本文介绍了正在向Gmail帐户发送消息...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我想使用.net将消息发送到多个gmail,yahoo和hotmail帐户.
你能帮我这个忙吗?.
感谢朋友..
Hi Friends,
I want to send a message to multiple gmail, yahoo and hotmail accounts by using .net.
Can you please help me in this ....
THANKS friends..
推荐答案
string from ="test@gmail.com"; //Replace this with your own correct Gmail Address
string to = "test1@gmail.com";//Replace this with the Email Address to whom you want to send the mail
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "One Ghost", System.Text.Encoding.UTF8);
mail.Subject = "This is a test mail";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "This is Email Body Text";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(from, "********");
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{
client.Send(mail);
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
HttpContext.Current.Response.Write(errorMessage);
} // end try
http://csharp.net -informations.com/communications/csharp-smtp-mail.htm [
http://csharp.net-informations.com/communications/csharp-smtp-mail.htm[^] might help you.
尝试Google
try Google
Sending mail in asp.net
这篇关于正在向Gmail帐户发送消息...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文