User Guide
Creating and Using COM Objects 375
• local An out-of-process server object (typically an exe file) that is running
outside the ColdFusion process space but running locally on the same server.
•
remote An out-of-process server object (typically an exe file) that is running
remotely on the network. If you specify
remote, you must also use the server
attribute to identify where the object resides.
Setting properties and invoking methods
The following example, using the sample Mailer COM object, shows how to assign
properties to the mail message you want to send and how to execute component
methods to handle mail messages.
In the example, form variables provide method parameters and properties, such as
the name of the recipient, the desired e-mail address, and so on.
<!--- First, create the object --->
<cfobject type="COM"
action="Create"
name="Mailer"
class="CDONTS.NewMail">
<!--- 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.From = "#Form.fromName#">
<cfset Mailer.To = "#Form.to#">
<cfset Mailer.Subject = "#Form.subject#">
<cfset Mailer.Importance = 2>
<cfset Mailer.Body = "#Form.body#">
<cfset Mailer.Cc = "#Form.cc#">
<!--- Last, use the Send() method to send the message.
Invoking the Send() method destroys the object.--->
<cfset Mailer.Send()>
Note
Use the
cftry and cfcatch tags to handle exceptions thrown by COM objects. For
more information on exception handling, see “Handling Exceptions in ColdFusion”
on page 204.