<% ' Sample ASP code to send mail using CDO for Windows 2000 ' References (more are further below): ' http://msdn.microsoft.com/library/en-us/dncdsys/html/cdo_roadmap.asp ' http://msdn.microsoft.com/library/en-us/cdosys/html/ecdb51f4-5ba0-46d8-9c7c-7e4154a18f50.asp ' http://msdn.microsoft.com/library/en-us/cdosys/html/4ca290b4-e701-4e4b-96df-ae000af9b239.asp ' Putting the Configuration Object in the ASP Session ' http://msdn2.microsoft.com/en-us/library/ms526308.aspx Dim Subject, HTMLBody, TextBody, ErrorDescription Call CreateMessageBody Call SendEmail Sub CreateMessageBody ' These can be named anything so long as they're referenced correctly when actually sending the mail (further below) Subject = "Test message using CDO for Windows 2000" ' If you're not going to send your message in HTML format, then the HTMLBody ' can be skipped here and when the message is actually sent (further below). HTMLBody = "" & vbcrlf _ & "" & vbcrlf & "" & vbcrlf & " " & Subject & "" & vbcrlf _ & " " & vbcrlf _ & "" & vbcrlf & "" _ & "

This should be in HTML format, but will " _ & "display an auto-rendered plain-text format for email clients that can't read it correctly. " _ & "The auto-rendered plain-text is ok for basic HTML content, but the TextBody option " _ & "should be used in conjunction with HTMLBody to display a better-formatted plain-text " _ & "portion of the message when the email client doesn't support HTML-formatted messages.

" _ & "" & vbcrlf & "" TextBody = "This is the body of the message in plain-text. If TextBody and HTMLBody are BOTH used, " _ & "the TextBody value will override the auto-rendered plain-text portion of the HTML-formatted " _ & "email when the email client doesn't support HTML-formatted messages." End Sub Sub SendEmail ' Connect to the mail server and send the mail %> <% ' http://msdn.microsoft.com/library/en-us/cdosys/html/39186eaa-c4c1-430a-9715-35e291925c5c.asp Dim iMsg, iConf Set iMsg = Server.CreateObject("CDO.Message") Set iConf = iMsg.Configuration ' http://msdn.microsoft.com/library/en-us/cdosys/html/37be0471-06bd-489d-8bf2-5c22bb7ce17c.asp With iConf.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort ' http://msdn.microsoft.com/library/en-us/cdosys/html/bb2a4e60-080f-49bf-be71-e2a7e52ce5ad.asp .Item(cdoSMTPServer) = "smtp.mydomain.com" ' http://msdn.microsoft.com/library/en-us/cdosys/html/d1c332e6-a675-47be-9c13-8f612169a5d2.asp ' .Item(cdoSMTPConnectionTimeout) = 45 ' http://msdn.microsoft.com/library/en-us/cdosys/html/dacb41e4-a26f-4475-9ef8-665ab6374fb1.asp .Update End With ' http://msdn.microsoft.com/library/en-us/cdosys/html/39186eaa-c4c1-430a-9715-35e291925c5c.asp With iMsg ' Email address fields (To, Cc, Bcc, From) are formatted like the following: ' (don't forget to escape any required double-quotes) ' "John Doe" , , "My Company, Inc." , smithers@blah.org .To = """A. Smith"" " ' .Cc = "someoneelse@whateversfsdsf.com, ""John Doe"" , sdfsdf@wadladejde.org" ' .Bcc = """Jane Doe"" , sdfsdfad@sdaglenwds.com" .From = """Some Name"" " .Subject = Subject ' Retrieve this from the string further above ' .BodyPart.Charset = "us-ascii" ' default appears to be "iso-8859-1" although Microsoft states otherwise. .HTMLBody = HTMLBody ' Retrieve this from the string further above .TextBody = TextBody ' Retrieve this from the string further above End With On Error Resume Next iMsg.Send If Err.Number <> 0 Then ErrorDescription = Err.Description End If On Error Goto 0 Set iMsg = Nothing Set iConf = Nothing End Sub Sub DisplayMailError %> Error sending email

Your message was NOT sent:
Error: <%=ErrorDescription%>

<% End Sub %>