From dePoPo.net

Sending email from your webserver

Posted in: ASP
By dePoPo
Mar 25, 2009 - 4:49:53 PM

This sample shows several examples of how to send email using the CDO object from ASP pages. CDO is the successor to the discontinued CDONTS object when it comes to sending mail from ASP.
<%
    ' --- send basic text email
    
    set mymessage = createobject("CDO.Message")
    mymessage.subject = "The subject line"
    mymessage.from = "sender@mydomain.com"
    mymessage.to = "receipient@mydomain.com"
    mymessage.textbody = "This is a message"
    mymessage.send
    set mymessage = nothing
    
    
    ' --- send html email
    set mymessage = createobject("CDO.Message")
    mymessage.subject = "The subject line"
    mymessage.from = "sender@mydomain.com"
    mymessage.to = "receipient@mydomain.com"
    mymessage.htmlbody = "<b>This is a message</b>"
    mymessage.send
    set mymessage = nothing

    ' --- You can also create a html body from an existing webpage
    mymessage.CreateHTMLBody "http://www.dePoPo.net"
    
    ' --- Or from a localy stroed html file
    mymessage.CreateHTMLBody "file://c:/somefile.htm"
    
    ' --- Add an attachment to the message with
    mymessage.addatachment "c:\somedirectory\somefile.pdf"
   
%>

© Copyright 2010 by dePoPo.net