<!--- Second, 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
information on exception handling, see
tags," on page
299.
Releasing COM objects
By default, COM object resources are released when the Java garbage collector cleans them. You
can use the
ReleaseCOMObject
needed.
Use the
ReleaseCOMObject
process, such as Microsoft Excel. The garbage collector might not clean these processes in a short
time, resulting in multiple external processes running, which drains system resources.
If the COM object has an end method, such as a quit method that terminates the program, call
this method before you call the
function on an object that is in use, the object is prematurely released and your application will
get exceptions.
Example
The following example creates a Microsoft Excel application object, uses it, then releases the
object when it is no longer needed:
<h3>ReleaseComObject Example</h3>
<cfscript>
obj = CreateObject("Com", "excel.application.9");
//code that uses the object goes here
obj.quit();
ReleaseObject(obj);
</cfscript>
General COM object considerations
When you use COM objects, consider the following to prevent and resolve errors:
•
Ensuring correct threading
•
Using input and output arguments
•
Understanding common COM-related error messages
The following sections describe these issues.
and
tags to handle exceptions thrown by COM objects. For more
cfcatch
Chapter 14, "Handling runtime exceptions with ColdFusion
function to immediately release resources if an object is no longer
function to release COM objects that are launched as an external
ReleaseComObject
function. If you use the
Creating and using COM objects
ReleaseComObject
769
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers