对产品质量来说,不是100分就是0分
SMTPClient邮件发送代码
上一篇 /
下一篇 2007-06-25 09:42:48
/ 个人分类:C#
protected void btnSendEmail_Click(object sender, EventArgs e)51Testing软件测试网4N+JLz_%^p
{51Testing软件测试网 S5|!n(| ]&?|7p
string smtpserver = "smtp.163.com";51Testing软件测试网%g
GL#V,a
string username = "user";
F!Ps:W%{V0 string userpwd = "psw";
6Qi^J*^!?_0 string emailfrom = "from@163.com";51Testing软件测试网HB;@6Rm}5FI$`v-r
Jnqv.|D0V0 SmtpClient client = new SmtpClient(smtpserver);51Testing软件测试网D_;@+F.\W} UB#I
client.Credentials = new NetworkCredential(username,userpwd);51Testing软件测试网r`0B`!Ujpq
client.DeliveryMethod = SmtpDeliveryMethod.Network;51Testing软件测试网G&v8j(GB
client.UseDefaultCredentials = false;
F!b
I"x3u5J5?wY.v0 client.EnableSsl = false;
@4z:g&O!|;Q-Pc051Testing软件测试网E,lbv r? MailMessage email = new System.Net.Mail.MailMessage();51Testing软件测试网$u9r [Iw9}/yS,P,OUOJ
email.From = new MailAddress(emailfrom);51Testing软件测试网)uS!f5E9\]m5c
email.To.Add("user@163.com");51Testing软件测试网 QX:w9mg&v
L
email.Body = "这是一封测试邮件";51Testing软件测试网 opQ P5u6]
email.BodyEncoding = System.Text.Encoding.UTF8;
9H'tE\:I0 email.Subject = "测试邮件";
a^2Gb:A^R0 email.SubjectEncoding = System.Text.Encoding.UTF8;
}H2?[/N)_`Y0 email.IsBodyHtml = true;
6z|;^2UL0eN
P0"l0e_9y ei*C9_0 client.Send(email);51Testing软件测试网n7L#Y`&?tzD~q\
Z'j+~5H/g }0为什么总提示:
tGCBQ051Testing软件测试网
g3[)pL{K"ASystem.Net.Mail.SmtpException51Testing软件测试网`B+?^\st b8e
Message="不允许使用邮箱名称。 服务器响应为: authentication is required,smtp2,wKjRDLD7vAi3O35GQKXWAA==.12473S2 1182677943"
8zO
hE|+PK pM
tC0Source="System"51Testing软件测试网ed9VQ2O6Q
StackTrace:
#Atg]Hm0在 System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
D!Wn
ZO#T0在 System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
;Y+IbM8L0p0在 System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)51Testing软件测试网I&qf\iN
在 System.Net.Mail.SmtpClient.Send(MailMessage message)
[V$yt+f0在 Default.btnSendEmail_Click(Object sender, EventArgs e)51Testing软件测试网R;P(l:}1o]kV
51Testing软件测试网gn hQ.l怎么回事啊!!
+YA6\"]Wl%Y0
收藏
举报
TAG:
smtpclient
邮件发送
不允许使用邮箱名称
authentication
is
required