首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

惊人求救(发邮件不成功)

2011-12-19 
紧急求救(发邮件不成功)M_mail.Fromthis.TextBox4.Text//发信人M_mail.Tothis.TextBox1.Text//收件人M

紧急求救(发邮件不成功)
M_mail.From   =   this.TextBox4.Text;                       //发信人
                M_mail.To   =   this.TextBox1.Text;                           //收件人
                M_mail.Subject   =   this.TextBox3.Text;                 //标题
                M_mail.Body   =   this.TextBox5.Text;                       //正文
                //优先级
                M_mail.Priority   =   MailPriority.Normal;            
                if(this.DropDownList1.Text== "高 ")
                {
                        M_mail.Priority   =   MailPriority.High;
                }
                else   if   (this.DropDownList1.Text   ==   "低 ")
                {   M_mail.Priority   =   MailPriority.Low;   }

                //正文格式
                M_mail.BodyFormat   =   MailFormat.Text;
                if   (this.DropDownList2.Text   ==   "HTML格式 ")
                {   M_mail.BodyFormat   =   MailFormat.Html;   }
                M_mail.BodyEncoding   =   System.Text.Encoding.UTF8;

                //添加抄收人
                if   (this.TextBox2.Text   !=   " ")
                {
                        M_mail.Cc   =   this.TextBox2.Text.ToString();
                }

  //发送邮件
                try
                {
                        //设置服务器验证
                        M_mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");
                        //验证用户名
                        M_mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", "lu ");
                        //验证密码
                        M_mail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ",   "123 ");
                        SmtpMail.SmtpServer   =   "smtp.163.com ";


                        SmtpMail.Send(M_mail);
                        this.ClientScript.RegisterClientScriptBlock(this.GetType(),   "send   success! ",   "alert( '发送成功! '); ",   true);
                }
                catch(Exception   err)
                {
                        this.ClientScript.RegisterClientScriptBlock(this.GetType(),   "err2! ",   "alert( ' "+err.Message+ " '); ",   true);
                }

我以前测试可以发送成功,不知道为什么现在发不了了,
求高手指教!多谢

[解决办法]
using System.Web.Mail;


MailMessage objMailMessage;
MailAttachment objMailAttachment;

// 创建一个附件对象
objMailAttachment = new MailAttachment( "d:\\test.txt " );//发送邮件的附件
// 创建邮件消息
objMailMessage = new MailMessage();
objMailMessage.From = "mysina@sina.com ";//源邮件地址
objMailMessage.To = "scucj@126.com ";//目的邮件地址,也就是发给我哈
objMailMessage.Subject = "邮件发送标题:你好 ";//发送邮件的标题
objMailMessage.Body = "邮件发送标内容:测试一下是否发送成功! ";//发送邮件的内容
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 ", "mysina ") ;
//密码
objMailMessage.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", "chenjie ");

//如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied

//SMTP地址
SmtpMail.SmtpServer = "smtp.sina.com.cn ";

//开始发送邮件
SmtpMail.Send( objMailMessage );
[解决办法]
发送的时候 没有错误提示吗 smtp服务器 是不是把你这个邮箱点垃圾关闭了 换一个试试
[解决办法]
接分了
[解决办法]
换个邮箱看看
[解决办法]
.net发邮件错误,出现的问题稀奇古怪的.我也碰到过,就是一阵好使一阵不好使.改过很多次都这样.无耐就扔那了.

热点排行