一个Jmail发送邮件的例子
另附源文件:[attach]593[/attach]
[color=Red]注意:红色标记处为需要改的地方,只要把它们改为能够支持jmail发送的邮箱即可。[/color]
asp:sendmail.asp
<%
cname=request.Form("fullname")
cemail=request.Form("email") '[color=green]接受要发送的email[/color]
sex=request.Form("sex")
emailtitle=request.Form("TITLE")
companyname=request.Form("COMPANY NAME")
mailaddress=request.Form("Mail Address")
postal_code=request.Form("COUNTRY/POSTAL CODE")
fax=request.Form("COUNTRY CODE-AREA CODE-FAX NUMBER")
phone=request.Form("TELEPHONE NUMBER")
email=request.Form("email")
wearea=request.Form("We are a")
customers=request.Form("Our customers are mostly")
interested=request.Form("interested")
send_info=request.Form("Please send us the following information")
supplier=request.Form("More message to supplier")
Set JMail = Server.CreateObject("JMail.Message")
'是否将信头编码成iso-8859-1字符集. 缺省是True
JMail.ISOEncodeHeaders = True
'如果JMail.silent设置为true,ErrorCode包含的是错误代码
JMail.Silent = True
'设置标题和内容编码,如果标题有中文,必须设定编码为gb2312
JMail.Charset = "gb2312"
'JMail.ContentType = "text/html" '如果发内嵌附件一定要注释掉这行,重要!
JMail.From = "aoyun@tofor.com" ' [color=Red]发送者地址[/color]
JMail.FromName = "panfine" ' 发送者姓名
JMail.MailServerUserName = "aoyun@tofor.com" ' [color=Red]身份验证的用户名[/color]
JMail.MailServerPassword = "aoyun2008" ' [color=Red]身份验证的密码[/color]
'加入新的收件人
JMail.AddRecipient cemail, cname
'JMail.AddRecipientBCC Email '密件收件人的地址
'JMail.AddRecipientCC Email '邮件抄送者的地址
JMail.Subject = emailtitle
JMail.Body = emailcontant
emailcontant=Sex&" "&cname&"<br>Fullname: "&cname&"<br>Title: "&emailtitle&"<br>Company Name: "&companyname&"<br>Mailing Address: "&mailaddress&"<br>Country/postal code: "&postal_code&"<br>Country code-Area code-fax number: "&fax&"<br>Telephone number: "&phone&"<br>E-mail address: "&email&"<br>We are a: "&wearea&"<br>Our customers are mostly: "&customers&"<br>We're interested in purchasing the following products and quantity: "&interested&"<br>Above listed products: "&send_info&"<br>More message to Panfine Group: "&supplier
'增加一个普通附件
'JMail.AddAttachment(Server.MapPath())
'增加一个嵌入式附件
' The return value of AddAttachment is used as a
' reference to the image in the HTMLBody.
'contentId = JMail.AddAttachment(Server.MapPath("images/email.gif"))
'只有HTML格式支持嵌入图片附件,我们采用HTML格式的邮件内容
' As only HTML formatted emails can contain inline images
' we use HTMLBody and appendHTML
JMail.HTMLBody = "<html><body><br>"&emailcontant
JMail.appendHTML "<br><br></body></html>"
'如果对方信箱不支持HTML格式邮件,我们仍需要给他一个友善的提示
' But as not all mailreaders are capable of showing HTML emails
' we will also add a standard text body
JMail.Body = "Too bad you can't read HTML-mail."
JMail.appendText " "
if JMail.Send( "mail.tofor.com" ) then '执行邮件发送(通过邮件服务器地址)smtp.域名.com 不一定是邮件服务器
response.Write("发送成功!")
else
response.Write("发送失败!")
end if
JMail.Close()
Set JMail = Nothing
%>
前台文件太长了,只把后台发送代码贴出,前台文件请下载源文件。
页:
[1]
