2 Option Explicit
3
4 Dim objMail
5 Dim strSubject
6 Dim strBody
7
8 strSubject = "This is a test email"
9 strBody = "This test email is using [email protected] " & _
10 " as the sender email address but we are " & _
11 " using [email protected] as the Reply-To header."
12
13
14 ' First create an instance of NewMail Object
15 Set objMail = Server.CreateObject("CDONTS.NewMail")
16
17 ' Please replace the "From" and "To" email addresses with your
18 ' own valid email address. I recieve too many emails
19 ' from people who test this sample and keep sending
20 ' emails to [email protected], or they keep the "From" property
21 ' as [email protected] and I get response of
22 ' undeliverable emails.
23 ' NOTE: If the "To" or "From" properties of CDONTS contain
24 ' invalid email address you will not recieve the email.
25
26 objMail.From = "[email protected]"
27 objMail.To = "[email protected]"
28
29 ' Use the value property of the CDONTS.NewMail Object
30 ' to Set the Reply-To header
31
32 objMail.Value("Reply-To") = "[email protected]" '回复邮件地址
33
34 objMail.Subject = strSubject
35 objMail.Body = strBody
36
37 objMail.Send
38
39 Set objMail = Nothing
40 %>
41
42
43
44
45 <%
46
47 strText = "Test"
48
49 Const cdoSendUsingPort = 2
50
51 Const strSmartHost = "myLocalSMTPHost"
52
53 Set myMail = CreateObject("CDO.Message")
54
55 Set iConf = myMail.Configuration
56
57 With iConf.Fields
58
59 .item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
60
61 .item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
62
63 .Update
64
65 End With
66
67 With iConf.Fields
68
69 .item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
70
71 .item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
72
73 .Update
74
75 End With
76
77 With myMail
78
79 myMail.From = "[email protected]"
80
81 myMail.To = "[email protected]"
82
83 myMail.ReplyTo = "[email protected]" '回复邮件地址
84
85 myMail.Subject = "Internet Communication from Me"
86
87 myMail.HTMLBody = strText
88
89 myMail.Send
90
91 End With
92
93 Set myMail = Nothing
94
95 %>
96
97