Setting Properties and Invoking Methods  
 
 

The following example, using a hypothetical SMTPMailer COM object, shows how you can assign properties to the mail message you want to send, and how you execute component methods in order to handle mail messages. In the example, form variables are used to provide method parameters and properties, such as the name of the recipient, the desired email address, and so on.

<!--- First, create the object --->

<CFOBJECT ACTION="Create"
    NAME="Mailer"
    CLASS="SMTPsvg.Mailer">

<!--- Then, use the form variables from the 
user entry form to populate a number of properties 
necessary to create and send the message. --->

<CFSET Mailer.FromName = #form.fromname#>
<CFSET Mailer.RemoteHost = #RemoteHost#>
<CFSET Mailer.FromAddress = #form.fromemail#>
<CFSET Mailer.Subject = "Testing CFOBJECT">
<CFSET Mailer.BodyText = "#form.msgbody#">
<CFSET Mailer.SMTPLog = "#logfile#">

<!--- Last, use the AddRecipient and SendMail 
methods to finish and send the message along --->

<CFSET Mailer.AddRecipient("#form.fromname#","#form.fromemail#")>
<CFSET success=Mailer.SendMail()>

<!--- First, create the object --->

<CFOBJECT ACTION="Create"
    NAME="Mailer"
    CLASS="SMTPsvg.Mailer">

<!--- Then, use the form variables from the 
user entry form to populate a number of properties 
necessary to create and send the message --->

<CFSET Mailer.FromName = #form.fromname#>
<CFSET Mailer.RemoteHost = #RemoteHost#>
<CFSET Mailer.FromAddress = #form.fromemail#>
<CFSET Mailer.Subject = "Testing CFOBJECT">
<CFSET Mailer.BodyText = "#form.msgbody#">
<CFSET Mailer.SMTPLog = "#logfile#">

<!--- Last, use the AddRecipient and 
SendMail methods to finish and send 
the message along --->

<CFSET Mailer.AddRecipient("#form.fromname#","#form.fromemail#")>
<CFSET success=Mailer.SendMail()>


 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.