1 Reply Latest reply on Aug 20, 2007 8:11 AM by cf_dev2



      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 item.name is " http://schemas.microsoft.com/cdo/configuration/sendusing">
      <cfset item.value = 2>
      <cfif item.name is " http://schemas.microsoft.com/cdo/configuration/smtpserver">
      <cfset item.value = "">
      <cfif item.name is " http://schemas.microsoft.com/cdo/configuration/smtpserverport">
      <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.

      :) DavidP_OH