
How to send plain text emails that are HTML formatted? |
<%
@language = VBScript %>
<%
option explicit
dim objMail, htmlBodyText
set
objMail = server.createobject (CDONTS. Newmail)
htmlBodyText =
<! DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 TRANSITIONAL//
EN >
htmlBodyText = htmlBodyText & <html>
htmlBodyText
= htmlBodyText & <head>
htmlBodyText = htmlBodyText & <title>A
New Website is Launched</title>
htmlBodyText = htmlBodyText & </head>
htmlBodyText
= htmlBodyText & <body bgcolor = #GAEFA>
htmlBodyText
= htmlBodyText & <right>
htmlBodyText = htmlBodyText &
<p> A brand new website that teaches ''
htmlBodyText = htmlBodyText
& ASP Quickly and easily < a href = http://www.newdomainurlhere
>
htmlBodyText = htmlBodyText & http: // www. http://www.newdomainurlhere</a>.</p>
htmlBodyText
= htmlBodyText & <img src= someimage. Gif >
htmlBodyText = htmlBodyText & </center>
htmlBodyText
= htmlBodyText & </body>
htmlBodyText = htmlBodyText
& </html>
objMail. From =webmaster@newdomainurlhere
objMail.
To= someone@someoneurlhere
objMail. Subject = Learn ASP
Quickly
objMail. Bodyformat = 0
objMail. Mailformat = 0
objMail.body
= htmltext
objMail. AttachUrl server. Mapath ( someimage.gif),
someimage.gif
objMail. Send
set objmail = nothing
%>
The major part of this listing deals with creating the appropriate HTML text. It is standard HTML, and line 17 even includes an image. When you add images to your HTML message, you must change the mail and body format of your email message. The necessary changes are made in the lines 25 and 26
objMail.Bodyformat
= 0
objMail.Mailformat = 0
The body format determines whether the message is plin text (1) or can contain HTML (0). Next you must determine the mail format, which describes how the mail is composted: it can be either a text message (1) or a MIME formatted (0) message. When you attach files, you should use the MIME type, which leads to the final new statement in this example:
objMail.AttachUrl server.Mapath (softwing.gif), softwing.gif
when
using an image in the HTML message, you must specify its physical path as well
as URL path that can be used in the message (<IMG> tag) to refer to it.
By sending the email on line 31 using the well-known send method, it is on the
way to the destination address.
_______________________________________________________________________
FREE
Subscription
Subscribe to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ Recommended
Resource
through email. Keep yourself updated with latest
developments in the industry.
anyone.
We assure that your privacy is respected
and protected.