Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use ASPMAIL within a .cfm? 1

Status
Not open for further replies.

OldWilly

Programmer
Joined
Mar 1, 2002
Messages
66
I want to send an email to multiple addresses (but making each one to an individual). I know I can do this with a loop
using cfmail. But cfmail is very slow on our ISP due to high volumes and queues. However ASPMAIL goes thru very fast on this server. In order to use it, I guess I'll have to write an ASP program. But I was wondering if it was possible to inter-mingle CF and ASP code. ??
(passing variables and whatnot).
 
I'm not familiar with ASPMAIL, but if it's an add-on for ASP, it's probably a COM object. You can certainly call them from ColdFusion using <CFOBJECT>
 
Any chance of a code example?
 
OK, you got it. I'm using the documentation for ASPMail 4.x ( I've never used this component before, but this should serve as a general overview of how to use <CFOBJECT>. You'll have to look up the program ID (and make sure the context should be InProc) of the COM object using Microsoft OLEView (go to for details).
Code:
<cfobject type=&quot;COM&quot;
          name=&quot;objASPMail&quot;
          class=&quot;progID&quot;
          action=&quot;Create&quot;
          context=&quot;InProc&quot;>
<cfscript>
  objASPMail.FromName = &quot;Old Willy&quot;;
  objASPMail.FromAddress = &quot;oldwilly@tek-tips.com&quot;;
  objASPMail.RemoteHost = &quot;mySMTPServer.tek-tips.com&quot;;
  objASPMail.Subject = &quot;Look at my cool e-mail script&quot;;
  objASPMail.BodyText = &quot;Here's where the text of my message would go&quot;;
</cfscript>

<cfloop query=&quot;qryMyEmailRecipients&quot;>
  <cfset status = objASPMail.AddRecipient(&quot;#FName# #LName#&quot;,&quot;#EmailAddr#&quot;)>
  <cfif NOT status>
    <cfabort showerror=&quot;Error Occurred Adding Recipient #FName# #LName#&quot;>
  </cfif>
</cfloop>
<cfset status = objASPMail.SendMail()>
<cfif status>
  Mail sent.
<cfelse>
  <cfabort showerror=&quot;Error Occurred Sending Mail&quot;>
</cfif>
 
Thanks a heap !! Great help !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top