学习NO.1 发表于 2015-4-18 19:36:38

ASP.NET利用Jmail发送邮件

利用Jmail发送邮件private void SendMailByJmail()
5http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gifhttp://www.cnblogs.com/Images/dot.gif{
6http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////建立发邮件类
7http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   jmail.MessageClass oJmailMessage = new jmail.MessageClass();
8http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   
9http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**//// 字符集
10http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.Charset = "GB2312";
11http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
12http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////附件的编码格式
13http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.Encoding = "BASE64";
14http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.ContentType = "text/html";
15http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
16http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////是否将信头编码成iso-8859-1字符集
17http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.ISOEncodeHeaders = false;
18http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
19http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**//// 优先级
20http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.Priority = Convert.ToByte(1);
21http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   
22http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////发送人邮件地址
23http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.From = TxtEmail.Text.Trim();
24http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   
25http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////发送人姓名
26http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.FromName    = TxtName.Text.Trim();
27http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
28http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**//// 邮件主题
29http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.Subject    = txtSubject.Text.Trim();
30http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
31http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////身份验证的用户名
32http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.MailServerUserName = TxtSmtpUser.Text.Trim();
33http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
34http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////用户密码
35http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.MailServerPassWord = TxtSmtpPwd.Text.Trim();
36http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
37http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////添加一个收件人,抄送人和密送人的添加和该方法是一样的,只是分别使用AddRecipientCC和RecipientBCC两个属性
38http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif    ///要是需要添加多个收件人,则重复下面的语句即可。添加多个抄送和密送人的方法一样
39http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.AddRecipient(txtReciver.Text.Trim(),"","");
40http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif    if("" != upFile.PostedFile.FileName)
41http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    http://www.cnblogs.com/Images/dot.gif{
42http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif      string attpath = upFile.PostedFile.FileName;
43http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif         oJmailMessage.AddAttachment(@attpath,true,attpath.Substring(attpath.LastIndexOf(".")+1,3));//添加附件
44http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif   }
45http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
46http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    /**////邮件内容
47http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage.Body = txtContent.Text.Trim();
48http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
49http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif    if(oJmailMessage.Send(TxtSmtServer.Text.Trim(),false))
50http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    http://www.cnblogs.com/Images/dot.gif{
51http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif         Response.Write("发送成功!");
52http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif   }
53http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif    else
54http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifhttp://terrylee.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif    http://www.cnblogs.com/Images/dot.gif{
55http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif         Response.Write("发送失败,请检查邮件服务器的设置!");
56http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif   }
57http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif
58http://terrylee.cnblogs.com/Images/OutliningIndicators/InBlock.gif   oJmailMessage = null;
59http://terrylee.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif}
页: [1]
查看完整版本: ASP.NET利用Jmail发送邮件