Jmail发信的实例,模块化随时调用

一个用jmail发信的过程,及使用方法.
发信时,直接调用这个过程就行了。

1   
2**dim** str,HtmlBody   
3HtmlBody=  "

<html><body bgcolor="red" topmargin="40"><p align="center">I Love 2Yup!</p></body></html>

 1"    
 2str=JmailSend(  "hello"  ,  "ILoveYou"  ,  **true** ,HtmlBody,  "[email protected]"  ,  [email protected]  , 
 3
 4"hello"  ,  "smtp.sina.com.cn"  ,  "hello"  ,  "Password"  )   
 5  
 6**if** str=  "Y"  ** then    
 7** response  .  write  (  "发送成功"  )   
 8** else    
 9** response  .  write  (  "发送失败!请重试!"  )   
10** end if    
11** '=================================================   
12'函数名:JmailSend   
13'作 用:用Jmail发送邮件   
14'参 数:Subject 邮件标题   
15' Body 邮件内容   
16' Body 邮件内容   
17' isHtml 是否发送Html格式邮件 (  true  是)   
18' HtmlBody Html格式邮件内容   
19' MailTo 收件人Email   
20' From 发件人Email   
21' FromName 发件人姓名   
22' Smtp smtp服务器   
23' Username 邮箱用户名   
24' Password 邮箱密码   
25'返回值:JmailSend=  "N"  发送失败 JmailSend=  "Y"  发送成功   
26'~~~~~~~~~~suercool~~~~~   
27  
28'=================================================   
29  
30**function** JmailSend(Subject,Body,isHtml,HtmlBody,MailTo,From,FromName,Smtp,Username,Password)   
31**dim** JmailMsg   
32**set** JmailMsg=  server  .  createobject  (  "jmail.message"  )   
33JmailMsg.mailserverusername=Username   
34JmailMsg.mailserverpassword=Password   
35  
36JmailMsg.addrecipient MailTo   
37JmailMsg.from=From   
38JmailMsg.fromname=FromName   
39  
40JmailMsg.  charset  =  "gb2312"    
41JmailMsg.logging= ** true    
42** JmailMsg.silent=  **true**   
43  
44JmailMsg.subject=Subject   
45JmailMsg.body=Body   
46**if** isHtml= ** true  then  ** JmailMsg.htmlbody=HtmlBody   
47  
48** if  not  ** JmailMsg.send(Smtp) ** then    
49** JmailSend=  "N"    
50** else    
51** JmailSend=  "Y"    
52** end if    
53** JmailMsg.  close    
54**set** JmailMsg= ** nothing    
55end function  **   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus