C# 发送邮件的问题 ~~~ 求助阿 !!!急!!
使用C#编写了一个发送邮件的程序
向其他的邮箱里发送邮件都没有问题
但是向新浪邮箱里发送邮件的时候 邮件里就会有用来定义格式的HTML代码 。。。
求大神帮助 !!!
------解决方案--------------------新浪免费邮箱收信(pop3)服务器:pop3.sina.com.cn
新浪免费邮箱发信(smtp)服务器:smtp.sina.com.cn
新浪酷邮100邮箱收信(pop3)服务器:pop3.sina100.com
新浪酷邮100邮箱发信(smtp)服务器:smtp.sina100.com
新浪收费邮箱收信(pop3)服务器:pop3.vip.sina.com
新浪收费邮箱发信(smtp)服务器:smtp.vip.sina.com
新浪邮箱需要"smtp服务器要求身份验证选项"!!!
------解决方案--------------------新浪免费邮箱发信(smtp)服务器:smtp.sina.com.cn
------解决方案--------------------
public bool SendEmail(MailAddress From,MailAddress To,string subject,string body)
{
try
{
MailMessage message = new MailMessage(From, To);
message.Subject = subject;
message.Body = body;
SmtpClient client = new SmtpClient(smtpServer, Convert.ToInt32(smtpPort));
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Host = smtpServer;
client.Port = Convert.ToInt32(smtpPort);
client.Send(message);
return true;
}
static void Main(string[] args)
{
Email email = new Email();
string accountName = email.getConfig("accountName");
string smtpServer = email.getConfig("smtpServer");
string smtpPort = email.getConfig("smtpPort");
email.AccountName = accountName;
email.SmtpServer = smtpServer;
email.SmtpPort = smtpPort;
MailAddress From = new MailAddress("xxx@xxx.com", "Test");
MailAddress To = new MailAddress("xxx@xxx.com", "Test");
if (email.SendEmail(From, To, "Test", "Hello World!"))
{
Console.WriteLine("|------------------------------OK---------------------------|");
}
Console.ReadLine();
}
}