Frequently Asked Questions

Help Center Search

Using CDO to Send Email from Your Windows Shared Hosting Web Site

Print this Article
Comment on this Article
Last Updated: April 18, 2008 5:29 PM

Collaboration Data Objects (CDO) can be used to send email from Windows shared hosting Web sites running IIS 6 or IIS 7. The following code sample demonstrates how to use CDO to create and send email.

<%
sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"


' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
objConfig.Fields.Update


' Create and send the mail
Set objMail=CreateObject("CDO.Message")
' Use the config object created above
Set objMail.Configuration=objConfig
objMail.From="[email protected]"
objMail.To="[email protected]"
objMail.Subject="subject"
objMail.TextBody="body"
objMail.Send
%>