QuadComm e-commerce solutions
![]()
|
|
|||||||||||||||||||
|
||||||||||||||||||||
|
ASP Tip: Sending mail with CDOSYS object
Since Windows XP, Microsoft is not including CDONTS on its operating systems. Instead it uses the new and more powerful mail component CDOSYS that was already present in Windows 2000. It is still fairly simple to send a simple email although some more advanced functions are a bit more complex. In this article I'll show you how to send a simple email and how to add additional advanced configuration parameters. The Object (CDO.Message) has several properties and methods that you must know:
The following example is the simplest email you can send. As you can see it couldn't be easier:
<%
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody
sTo = "recipient@maildomain.com"
sFrom = "fromaddress@maildomain.com"
sSubject = "Insert here your subject text"
sTextBody = "Insert here your plain body text"
Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")
'Set key properties
objMail.From = sFrom
objMail.To = sTo
objMail.Subject= sSubject
objMail.TextBody = sTextBody
'Send the email
objMail.Send
'Clean-up mail object
Set objMail = Nothing
%>
The next example (see link to code below) shows a more complex scenario. The first thing it does in create a new configuration object in addition to the mail object. Then it applies settings to the configuration object like the SMTP server authentication (optional), the SMTP server name and port and whether the mail should be sent securely using SSL. The next step is configure the mail object with an optional CC address (if it is empty it won't set it) and send it. Do not forget to clean-up the mail objects by setting them to nothing once you're done with them. I hope you foud this useful!
Related articles: Author: Carlos Baez You can also submit your own code examples. Just e-mail them. Read the disclaimer. |
|