【Vegas原创】asp/html页面作为邮件正文发送
asp/html页面作为邮件正文发送的最快方法,就是把整个网页代码写成一个字符串,在发送邮件的时候把此字符串作为邮件正文发出去。
<%
TimeNow = FormatDateTime(Time,4)
If (TimeNow < "08:00") Then
yesterday=date-2
else
yesterday=date-1
End if
'...
dim strBody
strBody=""
strBody=strBody+"<meta http-equiv='Content-Type' content='text/html; charset=GB2312'>"
strBody=strBody+" <style type='text/css'> <!-- body { margin-left: 1cm; }"
strBody=strBody+" .style2 {font-family: Arial, Helvetica, sans-serif; font-size: 14px}"
strBody=strBody+" .style3 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; }"
strBody=strBody+" .style4 {font-family: Arial, Helvetica, sans-serif}"
strBody=strBody+" .style7 {font-family: Arial, Helvetica, sans-serif; color: #FF0000; font-weight: bold; }"
strBody=strBody+" .style8 { color: #003399; font-weight: bold; }"
strBody=strBody+" .style9 {font-family: Arial, Helvetica, sans-serif; color: #003399; }"
strBody=strBody+" .style10 {font-weight: bold}"
strBody=strBody+" .style11 { color: #333333; font-weight: bold; }"
strBody=strBody+" .style13 {font-family: Arial, Helvetica, sans-serif; color: #333333; font-weight: bold; }"
strBody=strBody+" .style14 { color: #000000; font-weight: bold; }"
strBody=strBody+" .style18 {font-family: Arial, Helvetica, sans-serif; color: #003399; font-weight: bold; }"
strBody=strBody+" --></style>"
strBody=strBody+" <table>"
' ...
strBody=strBody+" </tr>"
strBody=strBody+" </table>"
Response.Write strBody
'
'发送mail
path=Server.MapPath("Temp\Summary.xls")
set mail=CreateObject("jmail.Message")
mail.Charset ="gb2312"
mail.From ="**" 'from
mail.FromName="KPI Daily Reporting~~ "
mail.AddRecipient "**" 'to
' mail.MailDomain="mx.hichina.com"
' mail.MailServerUserName = "test@hichina.com"
' mail.MailServerPassWord = "*****"
mail.subject=Subject
mail.HTMLBody= strBody
mail.AddAttachment(path)
' On Error Resume Next
mail.Send("") 'smtp server
mail.close()
set mail=nothing
response.write date &"发送成功"
%>
</body>
</html>
TimeNow = FormatDateTime(Time,4)
If (TimeNow < "08:00") Then
yesterday=date-2
else
yesterday=date-1
End if
'...
dim strBody
strBody=""
strBody=strBody+"<meta http-equiv='Content-Type' content='text/html; charset=GB2312'>"
strBody=strBody+" <style type='text/css'> <!-- body { margin-left: 1cm; }"
strBody=strBody+" .style2 {font-family: Arial, Helvetica, sans-serif; font-size: 14px}"
strBody=strBody+" .style3 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; }"
strBody=strBody+" .style4 {font-family: Arial, Helvetica, sans-serif}"
strBody=strBody+" .style7 {font-family: Arial, Helvetica, sans-serif; color: #FF0000; font-weight: bold; }"
strBody=strBody+" .style8 { color: #003399; font-weight: bold; }"
strBody=strBody+" .style9 {font-family: Arial, Helvetica, sans-serif; color: #003399; }"
strBody=strBody+" .style10 {font-weight: bold}"
strBody=strBody+" .style11 { color: #333333; font-weight: bold; }"
strBody=strBody+" .style13 {font-family: Arial, Helvetica, sans-serif; color: #333333; font-weight: bold; }"
strBody=strBody+" .style14 { color: #000000; font-weight: bold; }"
strBody=strBody+" .style18 {font-family: Arial, Helvetica, sans-serif; color: #003399; font-weight: bold; }"
strBody=strBody+" --></style>"
strBody=strBody+" <table>"
' ...
strBody=strBody+" </tr>"
strBody=strBody+" </table>"
Response.Write strBody
'
'发送mail
path=Server.MapPath("Temp\Summary.xls")
set mail=CreateObject("jmail.Message")
mail.Charset ="gb2312"
mail.From ="**" 'from
mail.FromName="KPI Daily Reporting~~ "
mail.AddRecipient "**" 'to
' mail.MailDomain="mx.hichina.com"
' mail.MailServerUserName = "test@hichina.com"
' mail.MailServerPassWord = "*****"
mail.subject=Subject
mail.HTMLBody= strBody
mail.AddAttachment(path)
' On Error Resume Next
mail.Send("") 'smtp server
mail.close()
set mail=nothing
response.write date &"发送成功"
%>
</body>
</html>
喜欢请赞赏一下啦^_^