+ -
当前位置:首页 → 问答吧 → 如何用Jmail.Message实现下列同样的功能,请大虾们指教!

如何用Jmail.Message实现下列同样的功能,请大虾们指教!

时间:2011-12-26

来源:互联网

这是一个静态页面生成的代码,由于一些主机不支持CDO.Message组件,支持JJmail.Message组件。故求解!
ServerURL1=""&web_url&"/templete/shoupage.asp?time="&now()&""
set objfso = Server.CreateObject("Scripting.FileSystemObject") 
Set Mail1 = Server.CreateObject("CDO.Message")
Mail1.CreateMHTMLBody ServerURL1,31
AA=Mail1.HTMLBody
Set Mail1 = Nothing
set htmout = objfso.CreateTextFile(server.mappath("../index.html")) 
AA=replace(AA,"../images/","images/") 
AA=replace(AA,"../flash/","flash/")
htmout.write replace(AA,"../upfile/","upfile/")
htmout.close

作者: cornertree   发布时间: 2011-12-26

可以通过Jmail,CDO.Message 等组件,自己先设一个发件邮箱
客户输入的邮箱只能做为收件邮箱,当他们把邮箱输入正确后,点提交,进入发件过程,先读取你的发送的内容然后执行发件
如果你要发件给自己,像客户订单发送到你邮件一样 就要自己准备两个邮箱,一个做发件 一个做收件邮箱,客户输入的邮箱只是做为一个字串提交到你的邮箱里,
Jmail代码

Set jmail = Server.CreateObject("JMAIL.Message") '建立发送邮件的对象 
jmail.silent = true '屏蔽例外错误,返回FALSE跟TRUE两值j 
'mail.logging = true '启用邮件日志 
jmail.Charset = "GB2312" '邮件的文字编码为国标 
jmail.ContentType = "text/html" '邮件的格式为HTML格式 
jmail.AddRecipient Email '邮件收件人的地址 
jmail.From = "[email protected]" '发件人的E-MAIL地址 
jmail.MailServerUserName = "panshuwen010" '登录邮件服务器所需的用户名 
jmail.MailServerPassword = "******" '登录邮件服务器所需的密码 
jmail.Subject = fromname&"发送给你的邮件" '邮件的标题 
jmail.Body = cinfo '邮件的内容 
'jmail.Prority = 1 '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值 
jmail.Send("Server Address") '执行邮件发送(通过邮件服务器地址) 
jmail.Close() '关闭对象

,CDO.Message代码

'CDO.Message 发邮件
function send_mail(s_email,s_email2,s_topic,s_body) 

'参数说明
's_email: 主要邮件地址
's_email2: 备用邮件地址
's_topic: 邮件主题
's_body: 邮件内容

dim eAccount,vTmp,iConf,Flds,oMail
   
eAccount = "[email protected]" '这里是你的邮件服务器地址和登陆名,我用的是126的邮箱做的测试 

  vTmp = Split(eAccount, "@", -1, vbTextCompare) 

  Set iConf = server.CreateObject("CDO.Configuration") 
  Set Flds = iConf.Fields 
  Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort这里是发送邮件端口 
  Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = vTmp(1) 
  Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 '这里是SMTP服务器端口 
  Flds("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = eAccount 
  Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = eAccount 
  Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic 
  Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = vTmp(0) 
  Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "******" '我的126邮箱密码
  Flds.Update 

  set oMail = server.CreateObject("CDO.Message") 
  oMail.To = s_email 
If s_email2<>"" Then
oMail.CC = s_email2
End If
  oMail.Subject = s_topic  
  oMail.HTMLBody = s_body
  oMail.From = "[email protected]" '这里必须和上面的登陆名一致
   

  Set oMail.Configuration = iConf 
  oMail.MimeFormatted = True 
  oMail.AutoGenerateTextBody = True 
  oMail.Fields.Update 
  oMail.HTMLBodyPart.Charset = "gb2312" 
  oMail.Send 

  Set oMail = Nothing  
  Set Flds = Nothing 
  Set iConf = Nothing 
   
send_mail=true  
if err then 
  err.clear 
  send_mail=false 
end if 
end function
'调用CDO.Message
If send_mail("[email protected]","[email protected]","订单",vstr)=true Then '第一个是发送到邮件 第二个是备用邮箱可为空 第三个是邮件标题 第四个是邮件内容
response.write"<script>alert('提交成功!');location.href='products.asp';</script>"
Else
response.Write("发送失败,请将下面内容发送到[email protected]邮箱:<font color=""#FF0000"">")
response.Write(vstr)
response.Write("</font>")
response.End()
End If

作者: hefeng_aspnet   发布时间: 2011-12-27