using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
MailAddress to = new MailAddress("[email protected]");
MailAddress from = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";
// Use the application or machine configuration to get the
// host, port, and credentials.
SmtpClient client = new SmtpClient("smtp.163.com",25);
Console.WriteLine("Sending an e-mail message to {0} at {1} by using the SMTP host {2}.",
to.User, to.Host, client.Host);
client.Send(message);
Console.WriteLine("OK");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message+ex.Data);
}
}
}
}
错误:
不允许使用邮箱名称。 服务器响应为: sorry, that domain isn't in my list of allowe
d rcpthosts (#5.7.1)
这是怎么回事啊.................................................
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
MailAddress to = new MailAddress("[email protected]");
MailAddress from = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";
// Use the application or machine configuration to get the
// host, port, and credentials.
SmtpClient client = new SmtpClient("smtp.163.com",25);
Console.WriteLine("Sending an e-mail message to {0} at {1} by using the SMTP host {2}.",
to.User, to.Host, client.Host);
client.Send(message);
Console.WriteLine("OK");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message+ex.Data);
}
}
}
}
错误:
不允许使用邮箱名称。 服务器响应为: sorry, that domain isn't in my list of allowe
d rcpthosts (#5.7.1)
这是怎么回事啊.................................................
http://www.codeproject.com/useritems/SendMailUsingGmailAccount.asp