troubleshooting Question


Avatar of dapperry
dapperry asked on
Web Development SoftwareColdFusion Language
5 Comments1 Solution348 ViewsLast Modified:

I am trying to use CFOBJECT in order to send email using CDOSYS instead of using CFMAIL. The company I am contracting for is only using CF 5 (ugh). I've seen code online that describes its use, but I can not find any where an smtpserver, and port are specified. I was hoping someone could help. Here;s what I got, which I think should work, but doesn't:

      Mailer = createobject("COM","CDO.Message");
      Mailer.From = SenderAddress;
      Mailer.Subject = SubjectLine;
      Mailer.To = SendTo;
      Mailer.HTMLBody = holdMessage;
      Mailer.TextBody = holdMessageTextOnly;
      if (len(Attachments) gt 0)
      MailConfig= createobject("COM","CDO.Configuration");
<cfset fields = MailConfig.Fields">
<cfloop collection="fields" item="item">
      <cfif is "">
            <cfset item.value = 2>
      <cfif is "">
            <cfset item.value = "">
      <cfif is "">
            <cfset item.value = 25>
<cfset MailConfig.Fields.Update()>
<cfset Mailer.Configuration = MailConfig>
<cfset Mailer.send()>
<cfset Mailer = nothing>

I keep getting an error, which point to the cfloop line:

Invalid collection fields - must be a valid struct or COM object

Any help would be much appreciated.

:) David
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros