求一个完整的jmail发送到邮箱的事例!!!!!

peter_so 2010-10-14 09:53:12

求一个sap利用jmail发送邮件的事例、

要求内容是客户自己填写的

一定 要详细 谢谢

请不要乱给地址
...全文
198 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChinaXtHuLang 2010-10-14
  • 打赏
  • 举报
回复
直接复制另存为一个.asp文件。把该要修改的改成你的。再运行。就可以了。

<%
'smtp为邮件服务器名
'user为smtp邮件服务器上的邮件地址
'pwd为smtp邮件服务器上的邮件的密码
'sendto为要发送的邮件地址
'from发件人名
'subject为主题
'body为邮件内容
function sendmail(smtp,sendto,from,user,pwd,subject,body)
Set jmail = Server.CreateObject("JMAIL.Message") '建立发送邮件的对象
jmail.silent = true '屏蔽例外错误,返回FALSE跟TRUE两值j
jmail.logging = true '启用邮件日志
'加上如下语句,否则还有可能出现乱码的可能性:
jmail.Charset = "GB2312" '邮件的文字编码为国标
jmail.ContentTransferEncoding = "base64"
jmail.Encoding = "base64"
jmail.ISOEncodeHeaders = false

'jmail.ContentType = "text/html" '邮件的格式为HTML格式 -- 有此句则发送附件时为乱码
jmail.AddRecipient sendto '邮件收件人的地址
jmail.From = from '发件人的E-MAIL地址
jmail.MailServerUserName = user '登录邮件服务器所需的用户名
jmail.MailServerPassword = pwd '登录邮件服务器所需的密码
jmail.Subject = subject '邮件的标题
jmail.Body = body '邮件的内容
'jmail.AddAttachment Server.MapPath("login.gif")'附件--不能有此句:jmail.ContentType = "text/html"
'Jmail.AddAttachment Server.MapPath("b.rar") '否则附件会变成乱码
jmail.Priority = 3 '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
if jmail.send(smtp)=false then'执行邮件发送(通过邮件服务器地址)
sendmail=0
else
sendmail=1
end if
jmail.Close
end Function

'举例
smtp1="smtp.163.com"
user1="你的邮箱@163.com"
pwd1="邮箱的密码"
sendto1="要发送人的邮箱"
from1="你的邮箱@163.com" '要和user中的内容一样
subject1="邮件的主题"
body1="邮件内容"
t=sendmail(smtp1,sendto1,from1,user1,pwd1,subject1,body1)
if t=1 then
response.write "发送成功"
else
response.write "发送失败"
end if
%>
sy_binbin 2010-10-14
  • 打赏
  • 举报
回复
''发送电子邮件函数
'siteEmail 发送方邮箱
'smtp 邮箱主机地址
'emailUserName 邮箱用户名
'emailUserPWD 邮箱密码
'inceptEmail 接受邮件的邮箱地址
'sendName 发送人的名称
'sendTitle 邮件标题
'sendContent 邮件正文
sub EmailSend(siteEmail,smtp,emailUserName,emailUserPWD,inceptEmail,sendName,sendTitle,sendContent)
dim jmail
set jmail = CreateObject ("jmail.message") ''创建对象
jmail.Silent = true ''一般不用改
jmail.Charset = "gb2312" ''信件的语言编码
jmail.ContentType = "text/html" ''信件的格式html或纯文本
jmail.From = siteEmail ''发信人邮箱
jmail.FromName = sendName ''发信人姓名
jmail.Subject = sendTitle ''信件主题
jmail.AddRecipient inceptEmail ''收信人地址
jmail.Body = sendContent ''信件正文
jmail.MailServerUserName = emailUserName ''服务器登陆用户名(您的邮件地址)
jmail.MailServerPassWord = emailUserPWD ''服务器登陆密码(您的邮件密码)
jmail.Send(smtp) ''服务器地址
jmail.Close
set jmail = nothing
end sub


看来你还是没弄明白JMAIL啊!!

给你一个简单的吧
phuai007 2010-10-14
  • 打赏
  • 举报
回复
在来一个


<!--#include file="inc/conn.asp"-->
<!--#include file="inc/sqlin.asp"-->
<!--#include file="user/base64.asp"-->
<%
names=Checkstr(request("names"))
id=Checkstr(request("id"))
if id="" then
response.Write"错误,影片id丢失,发送失败,请与管理员联系。"
response.end
end if
address=request("address")
k=IsValidEmail(request("address"))
if k=true then

u_name=Checkstr(request.Cookies("u_name"))
u_name=deljs(u_name)
u_name=Base64decode(u_name)

if u_name<>""then
sql="select u_id from zt_user where [u_name] ='"+u_name+"'"
Call maxz.exec("",-1)
rs.open sql,conn,1,1
if rs.bof and rs.eof then
u_id=""
else
u_id=rs("u_id")
end if
end if

call maxz.conn_open
set rs=server.createobject("adodb.recordset")
rs.Open "select zt_id,zt_name,zt_type,zt_zy,zt_content from zt_data where zt_id="&id,conn,1,1
if rs.eof and rs.bof then
response.write "没有找到该影片或者已被删除,请检查影片id是否正确。"
else
zt_id=rs("zt_id")
zt_name=rs("zt_name")
zt_type=rs("zt_type")
if zt_type=1 then
zt_type="韩国"
zt_type1="hgj"
elseif zt_type=2 then
zt_type="日本"
zt_type1="rbj"
end if
zt_zy=rs("zt_zy")
s=deljs(rs("zt_content"))
s=replace(s,"<p>","")
s=replace(s,"</p>","")
s=replace(s,chr(10),"")
s=replace(s,chr(13),"<br>")
s=replace(s,chr(32)," ")
s=replace(s,chr(-24159),"<br>")
s=replace(s,""","""")
s=replace(s,"‘","""")
s=replace(s,"“","“")
s=replace(s,"”","”")
s=replace(s,"’","")
zt_content=s
end if

Email=address
subject="你的朋友"&names&"给你推荐了一部"&zt_type&"剧"
body="我现在正在看《"&zt_name&"》,觉得很好看,就推荐给你,有兴趣的话就看下吧,下面是该电视剧的介绍:<br><br>"
body=body&"影片名:"&zt_name&"<br>"
body=body&"类  型:"&zt_type&"电视剧<br>"
body=body&"演  员:"&zt_zy&"<br>"
'body=body&"在线播放地址:http://www.bbmoo.com/moviehtml/"&zt_type1&"_"&zt_id&".html<br>"
body=body&"观看地址:<a href=http://www.bbmoo.com/u_view.asp?url=moviehtml/"&zt_type1&"_"&zt_id&".html&uid="&u_id&">点击这里直接打开</a><br>"
body=body&"影片剧情介绍:"&zt_content&"<br><br>"
body=body&"<span style=""color:#0000FF"">上面地址保证安全无病毒,也没有弹窗和垃圾广告,请放心打开!</span>"

Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
JMail.ContentType = "text/html" '邮件的格式为HTML格式
JMail.From = "master@bbmoo.com" ' 发送者地址
JMail.FromName = "包谷猪日韩剧" ' 发送者姓名
JMail.Subject = subject ' 邮件主题
JMail.MailServerUserName = "master@bbmoo.com" '身份验证的用户名
JMail.MailServerPassword = "991260" ' 身份验证的密码
JMail.Priority = 1
'JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.AddRecipient(Email)
JMail.Body = body
JMail.Send("127.0.0.1")
JMail.Close()
Set JMail = Nothing

rs.close
conn.close
set rs=nothing
set conn=nothing
'response.Write endstr
response.Write"<script language=""javascript"" type=""text/javascript"">alert('邮件发送成功!');window.close();</script>"
else
response.write"你输入的地址:"&request("address")&" 是一个无效地址,请返回重新输入。<br><br>QQ邮箱格式为:QQ号码@qq.com,比如:41254874@qq.com"
end if
'response.End()
function IsValidEmail(email) '判断EMAIL格式是否有效的函数
dim names,name,i,c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.",c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1),".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%>


这些都是我以前做站时写的,用的是自己架设的邮件服务器
phuai007 2010-10-14
  • 打赏
  • 举报
回复
我给你一个


<!--#include file="conn.asp"-->
<!-- #include file="check.asp" -->
<%
'邮件发送 for maxcms 1.0
'作者:二十三 论坛id:phuai
'QQ:41729015
'-----------------------------
Server.ScriptTimeout=3600 '超时1小时
Response.Buffer=True
response.Write"正在读取今日更新信息...<br><br>"
response.Flush()
Call maxz.exec("", -1)
set rs = server.createobject("adodb.recordset")
sql="select zt_id,zt_name,zt_type,zt_lz,new_date from zt_data where year(new_date)="&Year(date)&" and month(new_date)="&month(date)&" and day(new_date)="&day(date)&""
rs.open sql,conn,1,1
body=""
i=1
do while not rs.eof
zt_id=rs("zt_id")
zt_name=rs("zt_name")
zt_type=rs("zt_type")
if zt_type=1 then
typ="hgj"
elseif zt_type=2 then
typ="rbj"
end if
zt_lz=rs("zt_lz")
new_date=rs("new_date")
rs.movenext

body=body&i&"、<span style=""font-size:14px;font-weight:bold;"">"&zt_name&"</span> <span style=""font-size:12px;color:#458B00"">"&zt_lz&"</span> <a href=""http://www.bbmoo.com/moviehtml/"&typ&"_"&zt_id&".html"" target=""_blank""><span style=""font-size:12px;"">观看</span></a><br>"
i=i+1
loop
'response.write body
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write"信息读取完毕,开始发送邮件...<br><br>"
response.Flush()
call maxz.conn_open
set rs=server.createobject("adodb.recordset")
rs.Open "select u_mail from zt_mail order by u_id desc",conn,1,1
if rs.eof and rs.bof then
response.write "目前还没有人订阅,不用发送邮件。"
response.end()
else
y=month(now)
r=day(now)

do while not rs.eof
Email=rs("u_mail") '接收邮件人的邮件地址
subject="包谷猪-"&y&"月"&r&"日更新日韩剧列表" '邮件主题
info="你好,欢迎使用邮件订阅,以下是今日最新更新的日韩剧详细信息,请你查阅:<br><br>"
info=info&body&"<br><br>"
info=info&"本邮件无法回复,如有问题请发邮件至41729015@qq.com 同时也请你不要将本邮件举报为广告或垃圾邮件,如果你以后不想收到我们的邮件,请<a href=""http://www.bbmoo.com/mail/mail.html"" target=""_blank"">点击这里退订</a>即可,谢谢!<br><br>"
'info=info&"如果你觉得本网站不错,请告诉你周围的朋友。我们的地址:http://www.bbmoo.com ,QQ群:14872479 欢迎你的加入"
'response.Write info
'response.End()
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
JMail.ContentType = "text/html" '邮件的格式为HTML格式
JMail.From = "master@bbmoo.com" ' 发送者地址
JMail.FromName = "包谷猪日韩剧" ' 发送者姓名
JMail.Subject = subject ' 邮件主题
JMail.MailServerUserName = "master@bbmoo.com" '身份验证的用户名
JMail.MailServerPassword = "991260" ' 身份验证的密码
JMail.Priority = 1
'JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.AddRecipient(Email)
JMail.Body = info
JMail.Send("127.0.0.1")
JMail.Close()
Set JMail = Nothing

rs.movenext
n=n+1
response.Write "向 "&Email&" 发送成功<br>"
response.flush
call Sleep(2) '延时4秒
loop
response.write"发送完毕,一共发送了"&n&"封邮件。<br>"

end if
rs.close
conn.close
set rs=nothing
set conn=nothing

Function Sleep(n) '单位秒s
Dim StartTime
StartTime = Timer
Do : Loop Until Timer>n+StartTime
End Function
%>
lionz1023 2010-10-14
  • 打赏
  • 举报
回复
<%
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True

' 发送者信息(可用变量方式赋值)
JMail.From = "someone@51windows.net" ' 发送者地址
JMail.FromName = "海娃" ' 发送者姓名
JMail.Subject = "邮件主题" ' 邮件主题

' 身份验证
JMail.MailServerUserName = "myusername" ' 身份验证的用户名
JMail.MailServerPassword = "mypassword" ' 身份验证的密码

' 设置优先级,范围从1到5,越大的优先级越高,3为普通
JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

' 加入一个收件人【变量email:收件人地址】可以同一语句重复加入多个
JMail.AddRecipient("someone@somehost.com")

' 加入附件【变量filename:附件文件的绝对地址,确保用户IUSR_机器名有访问的权限】
' 【参数设置是(True)否(False)为Inline方式】
'contentId = JMail.AddAttachment (Server.MapPath("jmail.asp"), True)

' 邮件主体(HTML(注意信件内链接附件的方式))
JMail.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""><style type=text/css>A:link { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000}A:visited {FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #666666}A:hover {COLOR: #ff6600; FONT-SIZE: 9pt; TEXT-DECORATION: underline}BODY {FONT-SIZE: 9pt} --></style></head><body><font color=red>邮件正文</font><br><font color=green>邮件正文</font><br><b>邮件正文</b></body></html>"

' 邮件主体(文本部分)
JMail.Body = "我们的邮件采用了HTML格式,但是您的邮件查看软件可能不支持。。。邮件正文,邮件正文,邮件正文"

' 发送【调用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send("smtp.163.com")

' 关闭并清除对象
JMail.Close()
Set JMail = Nothing

if err.number<>0 then
response.write "发送发送失败!"
else
response.write "邮件发送成功!"
end if
%>
peter_so 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 sy_binbin 的回复:]



从前台页面填写表单添加到数据库的你会做吗??

如果不会的话,建议找本基础的教材学下!
[/Quote]

这个会的

但是我要的是发送到邮箱 不是添加到数据库啊

为什么要添加到数据库捏
sy_binbin 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 peter_so 的回复:]
引用 1 楼 lionz1023 的回复:
发送成功 但是前台我不知道怎么写

就用户填写的 怎么调用后台捏[/Quote]


从前台页面填写表单添加到数据库的你会做吗??

如果不会的话,建议找本基础的教材学下!
yjflinchong 2010-10-14
  • 打赏
  • 举报
回复

Server.ScriptTimeout=1000
Response.Buffer=True
response.Write"正在读取今日更新信息...<br><br>"
response.Flush()
Call maxz.exec("", -1)
set rs = server.createobject("adodb.recordset")
sql="select zt_id,zt_name,zt_type,zt_lz,new_date from zt_data where year(new_date)="&Year(date)&" and month(new_date)="&month(date)&" and day(new_date)="&day(date)&""
rs.open sql,conn,1,1
body=""
i=1
do while not rs.eof
zt_id=rs("zt_id")
zt_name=rs("zt_name")
zt_type=rs("zt_type")
if zt_type=1 then
typ="hgj"
elseif zt_type=2 then
typ="rbj"
end if
zt_lz=rs("zt_lz")
new_date=rs("new_date")
rs.movenext

body=body&i&"、<span style=""font-size:14px;font-weight:bold;"">"&zt_name&"</span> <span style=""font-size:12px;color:#458B00"">"&zt_lz&"</span> <a href=""http://www.bbmoo.com/moviehtml/"&typ&"_"&zt_id&".html"" target=""_blank""><span style=""font-size:12px;"">观看</span></a><br>"
i=i+1
loop
'response.write body
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write"信息读取完毕,开始发送邮件...<br><br>"
response.Flush()
call maxz.conn_open
set rs=server.createobject("adodb.recordset")
rs.Open "select u_mail from zt_mail order by u_id desc",conn,1,1
if rs.eof and rs.bof then
response.write "目前还没有人订阅,不用发送邮件。"
response.end()
else
y=month(now)
r=day(now)

do while not rs.eof
Email=rs("u_mail") '接收邮件人的邮件地址
subject="包谷猪-"&y&"月"&r&"日更新日韩剧列表" '邮件主题
info="你好,欢迎使用邮件订阅,以下是今日最新更新的日韩剧详细信息,请你查阅:<br><br>"
info=info&body&"<br><br>"
info=info&"本邮件无法回复,如有问题请发邮件至41729015@qq.com 同时也请你不要将本邮件举报为广告或垃圾邮件,如果你以后不想收到我们的邮件,请<a href=""http://www.bbmoo.com/mail/mail.html"" target=""_blank"">点击这里退订</a>即可,谢谢!<br><br>"
'info=info&"如果你觉得本网站不错,请告诉你周围的朋友。我们的地址:http://www.bbmoo.com ,QQ群:14872479 欢迎你的加入"
'response.Write info
'response.End()
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
JMail.ContentType = "text/html" '邮件的格式为HTML格式
JMail.From = "master@bbmoo.com" ' 发送者地址
JMail.FromName = "包谷猪日韩剧" ' 发送者姓名
JMail.Subject = subject ' 邮件主题
JMail.MailServerUserName = "master@bbmoo.com" '身份验证的用户名
JMail.MailServerPassword = "991260" ' 身份验证的密码
JMail.Priority = 1
'JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.AddRecipient(Email)
JMail.Body = info
JMail.Send("127.0.0.1")
JMail.Close()
Set JMail = Nothing

rs.movenext
n=n+1
response.Write "向 "&Email&" 发送成功<br>"
response.flush
call Sleep(2) '延时4秒
loop
response.write"发送完毕,一共发送了"&n&"封邮件。<br>"

end if
rs.close
conn.close
set rs=nothing
set conn=nothing

Function Sleep(n) '单位秒s
Dim StartTime
StartTime = Timer
Do : Loop Until Timer>n+StartTime
End Function
%>



peter_so 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lionz1023 的回复:]
<%
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True
……
[/Quote]

发送成功 但是前台我不知道怎么写

就用户填写的 怎么调用后台捏
peter_so 2010-10-14
  • 打赏
  • 举报
回复

谁把前台后台都给我
frankrenping 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 sy_binbin 的回复:]
别的帖子不说

你就说这个帖子吧,大家发的例子里哪个不带注释的??

就算你不看JMAIL的帮助,看这些例子的注释也应该知道啥意思了吧!
[/Quote]
很简单的,LZ要搞清楚前台和后台,楼上给的是后台代码。
sy_binbin 2010-10-14
  • 打赏
  • 举报
回复
别的帖子不说

你就说这个帖子吧,大家发的例子里哪个不带注释的??

就算你不看JMAIL的帮助,看这些例子的注释也应该知道啥意思了吧!
peter_so 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 sy_binbin 的回复:]




晕了!你把客户自己填写好的信息放在jmail.Body = sendContent ''信件正文

这里不就可以了吗??

看来你真是没理解JMAIL里各个参数都啥意思
[/Quote]


不就是不理解,要不我怎么还发2次帖子
大哥你说的在详细点啦
sy_binbin 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 peter_so 的回复:]
\

感谢大家帮忙

你们给的都是直接发送已经填好的内容

我要的是让客户自己添的。

呵呵 谢谢 希望大家在给点例子
[/Quote]


晕了!你把客户自己填写好的信息放在jmail.Body = sendContent ''信件正文

这里不就可以了吗??

看来你真是没理解JMAIL里各个参数都啥意思
peter_so 2010-10-14
  • 打赏
  • 举报
回复
\

感谢大家帮忙

你们给的都是直接发送已经填好的内容

我要的是让客户自己添的。

呵呵 谢谢 希望大家在给点例子

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧