htmlemail.asp by Chris Garrett
1<HTML>
2
3<body bgcolor=white>
4
5<%
6
7if request.ServerVariables("REQUEST_METHOD") = "GET" then
8
9%>
10
11<form action="htmlemail.asp" method=post>
12<font face=verdana>
13Your Name <input type="text" name="strName"> Your EMail <input type="text" name="strEmail">
14<br>
15Recipient Email <input type="text" name="strTo">
16<p>
17
18<textarea cols=40 rows=4 name=message>Your message</textarea>
19
20</p>
21
22<input type=submit name=send value=Send>
23
24</form>
25
26<%
27
28else
29
30Set objMail = Server.CreateObject("CDONTS.NewMail")
31objMail.Importance = 1
32objMail.From = request("strName") & "<" & request("strEmail") & ">"
33objMail.To = request("strTo")
34objMail.Subject = "Example of HTML EMail with Embeded Image"
35
36' this is my messages HTML
37strMsg = "" & _
38"<html><body bgcolor=red>" & _
39"<a href=""http://www.RealWorldASP.com/""><img src=""logo.gif"" border=0 alt=""RealWorldASP"">" & _
40"</a><p><font face=verdana>Example of a HTML Email with embedded Image<P><br>" & _
41request("message") & _
42"</body></html>"
43
44' Set the format of the email to html, etc
45objMail.BodyFormat = 0
46objMail.MailFormat = 0
47objMail.Body = strMsg
48
49' attach our image file and Set the url to simply logo.gif
50objMail.AttachURL server.MapPath("logo.gif"), "logo.gif"
51objMail.Send
52
53' destroy the email object
54Set objMail = Nothing
55
56%>
57<h1>
58<font face=verdana>Message Sent, Thanks!</font>
59</h1>
60
61<% end if %>
62
63</body></html>