我的代码如下:结果虽然显示success,但邮箱力里却没有邮件,不知道为何???
//发送邮件:
MailMessage mailMess=new MailMessage();
mailMess.To="[email protected]";
mailMess.From="[email protected]";
for(int i=0;i<2;i++)
{
try
{
mailMess.Subject="你好帅哦 mail测试"+i*10;
mailMess.BodyFormat=MailFormat.Text;
mailMess.Body="希望你越来越帅\n这是一个含有附件的Email";
mailMess.Attachments.Add(new MailAttachment(Server.MapPath("mytext.txt")));
SmtpMail.Send(mailMess);
Response.Write("success!\n");
}
catch(Exception ex)
{
Response.Write(ex.Message+"\n");
}
//发送邮件:
MailMessage mailMess=new MailMessage();
mailMess.To="[email protected]";
mailMess.From="[email protected]";
for(int i=0;i<2;i++)
{
try
{
mailMess.Subject="你好帅哦 mail测试"+i*10;
mailMess.BodyFormat=MailFormat.Text;
mailMess.Body="希望你越来越帅\n这是一个含有附件的Email";
mailMess.Attachments.Add(new MailAttachment(Server.MapPath("mytext.txt")));
SmtpMail.Send(mailMess);
Response.Write("success!\n");
}
catch(Exception ex)
{
Response.Write(ex.Message+"\n");
}
解决方案 »
- 如何才能成为一个高手程序员?
- 急!!请问怎么获取一个论坛上的发帖回复更新,不用登陆该论坛?
- asp.net绑定数据的问题
- ASP.NET 项目使用DevExpress.Web.v9.2
- 请问“管道既支持同步读写操作,也支持异步读写操作。”该怎么理解?
- 怎么让网页中新发布的前三条新闻出现一个“gif图片”提示?
- 页面传值的问题,请教!!!!!!!
- 一篇文章(已生成静态html)内容太长时用1,2,3...把它分成多篇,怎么做?需要用asp程序实现。
- gridview,objectdatasource,dataset怎么实现这样的功能
- 请问,写控件的问题!
- 小弟不才,问一个论坛登录的问题
- 大家好,我有个问题要请教,dreamweaver连接access数据库脚本代码生成却看不到表 (表已建好) 是怎么一会事?有高手请指教,急用!!!
//验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//登陆名
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "yourUserName");
//登陆密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "yourPassword"); //发送
System.Web.Mail.SmtpMail.Send(mail);参考:http://blog.csdn.net/sykpboy/archive/2005/04/06/338710.aspx
mailMess.Subject="你好帅哦 mail测试"+i*10;
mailMess.BodyFormat=MailFormat.Text;
mailMess.Body="希望你越来越帅\n这是一个含有附件的Email";
mailMess.Attachments.Add(new MailAttachment(Server.MapPath("mytext.txt")));
SmtpMail.SmtpServer="smtp.163.com";
//验证
mailMess.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//登陆名
mailMess.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","peter3797");
//登陆密码
mailMess.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","×××××");
//发送
SmtpMail.Send(mailMess); Response.Write("success!\n");
jmail.Logging = true
jmail.From="[email protected]"
jmail.ReplyTo="[email protected]"
jmail.AddRecipient "[email protected]"
jmail.Subject="新用户注册!"
jmail.Body="用户注册信息"
jmail.MailServerUserName="brookes"
jmail.MailServerPassword="pass"
jmail.Send( "mail.server.com" )
jmail.Close
set jmail=nothingw3Jmail4 Jmail.Message参考:
(1)Body(信件正文) : 字符串
如:Jmail.Body = "这里可以是用户填写的表单内容,可以取自From。"
(2)Charset(字符集,缺省为"US-ASCII") : 字符串
如:Jmail.Charset = "US-ASCII"
(3)ContentTransferEncoding : 字符串
指定内容传送时的编码方式,缺省是"Quoted-Printable"
如:Jmail.ContentTransferEncoding = "base64"
(4)ContentType(信件的contentype. 缺省是"text/plain") : 字符串
如果你以HTML格式发送邮件, 改为"text/html"即可。
如:Jmail.ContentType = "text/html"
(5)Encoding : 字符串
设置附件编码方式(缺省是"base64)。 可以选择使用的是"base64", "uuencode" or "quoted-printable"
如:Jmail.Encoding = "base64"
(6)Log(Jmail创建的日志,前提loging属性设置为true,见下面) : 字符串
如:使用Response.Write( Jmail.Log )语句列出日志信息。
(7)Logging(是否使用日志) : 布尔型
如:Jmail.Logging = true
(8)Recipients : 字符串
只读属性,返回所有收件人
如:Response.Write( "" + Jmail.Recipients + "" );
(9)ReplyTo(指定别的回信地址) : 字符串
如:Jmail.ReplyTo = "[email protected]"
(10)Sender( 发件人的邮件地址) : 字符串
如:Jmail.Sender = "[email protected]"
(11)SenderName(发件人的姓名) : 字符串
如:Jmail.SenderName = "一克"
(12)ServerAddress(邮件服务器的地址) : 字符串
你可以指定多个服务器,用分号点开。可以指定端口号。
如果serverAddress保持空白,Jmail会尝试远程邮件服务器,然后直接发送到服务器上去。
如:Jmail.ServerAddress = "mail.263.net.cn"
(13)Subject(设定邮件的标题,可以取自From。):字符串
如:Jmail.Subject = "客户反馈表单"
(14)添加文件附件到邮件
如:Jmail.AddAttachment( "c:\anyfile.zip" )
(15)AddCustomAttachment( FileName, Data )
添加自定义附件.
如:Jmail.AddCustomAttachment( "anyfile.txt", "Contents of file" );
(16)AddHeader( Header, Value )
添加用户定义的信件标头。
如:Jmail.AddHeader( "Originating-IP","192.168.10.10" );
(17)AddRecipient(收件人):字符串
如:Jmail.AddRecipient( "[email protected]" );
(18)AddRecipientBCC( Email ),密件收件人:
如:Jmail.AddRecipientBCC( "[email protected]" );
(19)AddRecipientCC( Email ) ,抄送收件人:
如:Jmail.AddRecipientCC( "[email protected]" )
(20)AddURLAttachment( URL, 文档名)
下载并添加一个来自url的附件. 第二个参数"文档名", 用来指定信件收到后的文件名。
如:Jmail.AddURLAttachment( "http://www.chinabs.net/jmail.zip", "jmail" )
(21)AppendBodyFromFile( 文件名) ,将文件作为信件正文:
如:Jmail.AppendBodyFromFile( "c:\anyfile.txt" )
(22)AppendText( Text )
追加信件的正文内容,比如增加问候语或者其它信息。
如:Jmail.AppendText( "欢迎访问本站!" )
(23)Close() ,强制Jmail关闭缓冲的与邮件服务器的连接:
如:Jmail.Close()
(24)Execute() ,执行邮件的发送
如:Jmail.Execute()1.一定要给定jmail.MailServerUserName jmail.MailServerPassword,用于邮件服务器验证
2.去掉on error resume next调试,捕获错误信息。