对产品质量来说,不是100分就是0分
SMTPClient邮件发送代码
上一篇 /
下一篇 2007-06-25 09:42:48
/ 个人分类:C#
protected void btnSendEmail_Click(object sender, EventArgs e)51Testing软件测试网 X
fs@
UW
Q
{
gX6[x7E
L0 string smtpserver = "smtp.163.com";
v] yP1pTM lzl0 string username = "user";
p5[(I8|J8{0 string userpwd = "psw";
N_%];D7b9kDDJ0 string emailfrom = "from@163.com";
`:l"R(OD051Testing软件测试网.tE8]pe~*p SmtpClient client = new SmtpClient(smtpserver);
2kD/v"n@0v0 client.Credentials = new NetworkCredential(username,userpwd);51Testing软件测试网 N9U9@G2})O+c@%n{.w
client.DeliveryMethod = SmtpDeliveryMethod.Network;
ldoc I0 client.UseDefaultCredentials = false;
a-a
zv$W/^6H7Bo:Z(L^0 client.EnableSsl = false;
A0B7xK,mI
h0{EiSL#mL
N+L^0 MailMessage email = new System.Net.Mail.MailMessage();51Testing软件测试网6}0U!k/gU
email.From = new MailAddress(emailfrom);51Testing软件测试网9`V_|K~]o8|
email.To.Add("user@163.com");
*D
L/g#py+s o[8ui*[0 email.Body = "这是一封测试邮件";
2{,cAi4m#s"i+r0 email.BodyEncoding = System.Text.Encoding.UTF8;51Testing软件测试网;D4})pIe-J P"n
email.Subject = "测试邮件";
$~/ZPe1KL9k7U2{A0 email.SubjectEncoding = System.Text.Encoding.UTF8;51Testing软件测试网5Z*Z
V-bh
email.IsBodyHtml = true;51Testing软件测试网T
N^y'P'?3uHdk
51Testing软件测试网$SR ozizL4?Sr client.Send(email);51Testing软件测试网w2x-X!LK9kM~
51Testing软件测试网
s cl5@(g.B$S2k.A$]为什么总提示:
"s/SXU*d+|051Testing软件测试网v3f2K4DH5fSystem.Net.Mail.SmtpException
+SHz1z^#U{^0Message="不允许使用邮箱名称。 服务器响应为: authentication is required,smtp2,wKjRDLD7vAi3O35GQKXWAA==.12473S2 1182677943"51Testing软件测试网 ?x^"Z$|;XCC%BYIa
Source="System"
\.AnNd8vQ!_8R0x0StackTrace:51Testing软件测试网t4pKxW#p6y
在 System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
?$GKcj)R#eZ0在 System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
7u1P e7iRo0在 System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)51Testing软件测试网-d e-@j#Q
在 System.Net.Mail.SmtpClient.Send(MailMessage message)
Xo.H&Gm.Ac0在 Default.btnSendEmail_Click(Object sender, EventArgs e)51Testing软件测试网bP@|"d
Bx(K$zz
6Z~4~E"U&?%O w3p:}0怎么回事啊!!
n
Yd'@ GIzE0
收藏
举报
TAG:
smtpclient
邮件发送
不允许使用邮箱名称
authentication
is
required