protected void Button1_Click(object sender, EventArgs e)
{
System.Net.Mail.SmtpClient client = new SmtpClient();
client.Host = "localhost";
//client.UseDefaultCredentials = false;
//client.Credentials = new System.Net.NetworkCredential("[email protected]", "****");
//client.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new MailMessage();
//Encoding chtEnc = Encoding.GetEncoding(950);
message.From = new MailAddress("[email protected]","allen",Encoding.UTF8);
message.To.Add(new MailAddress("[email protected]", "xland", Encoding.UTF8));
message.Subject = "测试";
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.Body = "ceshi";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = false;
message.Priority = MailPriority.High;
object userstate = message; //client.SendAsync(message,userstate);
client.Send(message);
}
试了N次 (您也看到我的注释了)
.net下的JMAIL也试过
还是不行
为什么没有在代码中指定[email protected]的用户名和密码? smtpclient是不是要设置什么参数的?
邮件接受发送这方面没有涉及到过,关注这个问题,学习!
protected void Button1_Click(object sender, EventArgs e)
{
System.Net.Mail.MailMessage message = new MailMessage();
//Encoding chtEnc = Encoding.GetEncoding(950);
//message.From = new MailAddress("[email protected]", "firgoxland", Encoding.UTF8);
//message.To.Add(new MailAddress("[email protected]", "xland", Encoding.UTF8));
message.From = new MailAddress("[email protected]");
message.To.Add("[email protected]");
message.Subject = "测试邮件群发--xland";
message.SubjectEncoding = System.Text.Encoding.Default;
message.Body = "此邮件为邮件群发系统测试邮件<br>收到邮件者均为XLAND的兄弟,还望不要介意!<br>邮件群发系统1.0.0.080503_Alpha powered by Xland";
message.BodyEncoding = System.Text.Encoding.Default;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
//object userstate = message;
System.Net.Mail.SmtpClient client = new SmtpClient("smtp.163.com");
//client.Host = "smtp.163.com";
//client.UseDefaultCredentials = false;
System.Net.NetworkCredential smtpuserinfo = new System.Net.NetworkCredential();
smtpuserinfo.UserName = "firgoxland";
smtpuserinfo.Password = "***";
client.Credentials = smtpuserinfo; //client.SendAsync(message,userstate);
client.Send(message);
}最新版本的程序
IIS也重新装过了
错误依旧 在邮件标头中找到无效的字符 protected void Button1_Click(object sender, EventArgs e)
{ // 创建邮件消息
objMailMessage = new MailMessage();
objMailMessage.From = "[email protected]";
objMailMessage.To = "[email protected],[email protected]";
//objMailMessage.Cc = "[email protected]";
objMailMessage.Subject = "测试邮件群发--xland";
objMailMessage.Body = "此邮件为邮件群发系统测试邮件<br>收到邮件者均为firgo内部人员,还望不要介意!<br>邮件群发系统:1.0.0.080504_Alpha powered by firgo's Xland";//发送邮件的内容
objMailMessage.BodyFormat = MailFormat.Html;
//objMailMessage.Attachments.Add(objMailAttachment);//将附件附加到邮件消息对象中
//接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本 objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "****"); //如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied
//SMTP地址
SmtpMail.SmtpServer = "smtp.sina.com";
try
{
SmtpMail.Send(objMailMessage);
} catch (Exception ex)
{
return;
} }这样写就可以运行成功
不知道为什么
十分郁闷
技术大牛怎么还不出现!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
不应该啊,这个程序在别人的电脑上就能运行的???
刚才是修复的.net 我现在卸载 重新安装一次
我的机器名不知道被谁改成中文的了我汗机器名改成英文的就好用了
结帖给分 走人
顺便鄙视下CSDN的技术