11 Replies Latest reply: Oct 20, 2006 7:06 AM by Jfill RSS

    cfmailparam file argument doesnt work within events

    Gary__F Community Member
      I wrote a cfc to send emails and it uses cfmailparam to attach an optional image. It worked well so I turned it into an Asynchronous Event so users don't have to wait for it to process all of the emails. Again it worked well until I tried to include an image (which uses cfmailparam of course). A cfdump of #cfcatch# reported:

      String index out of range: -1
      It points to the line of code that has cfmailparam in it.

      What has a string error go to do with reading a file? This code worked perfectly when it wasn't run as an event. I tried replacing a dynamic file name with a hard coded file path but it makes no difference. I also tested cffile and it can read the gif as a binary and write as well.

      Is this a bug with cfmailparam running within an event? My code (for the cfmail part) is below:

      <CFMAIL query="recipients" to="#email#" from="Messaging <noreply@#request.AppInfo.email_domain#>" subject="#email_title#" replyto="noreply@#request.AppInfo.email_domain#" failto="failedmail@#request.AppInfo.email_domain#">
      <CFMAILPART type="html">
      <HTML><BODY bgcolor="white">
      <CFIF len(sender_logoPath)>
      <CFMAILPARAM file="#sender_logoPath#" disposition="inline" contentid="senderlogo">
      <IMG src="cid:senderlogo"><BR>
      </CFIF>
      #ParagraphFormat(newMessage.message_txt)#
      </BODY></HTML>
      </CFMAILPART>
      <CFIF IsDefined("image_url") and len(image_url)>
      <CFMAILPARAM file="#request.appInfo.imageattachment_path##image_url#_email.jpg" type="image/jpeg" disposition="attachment">
      </CFIF>
      </CFMAIL>


      Does anyone have an ideas please? To clarify, the code worked with cfmailparam when it was just a regular cfc called from a .cfm page, and as an event gateway it can send emails without attachments okay. The file attachments definately 100% exist. I've been working on this problem for 7 hours now. :-( Thanks.
      Gary.


      P.S. Here's the stack trace if it means anything to anyone:
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at coldfusion.tagext.net.MailParamTag.resolveUrl(MailParamTag.java:204) at coldfusion.tagext.net.MailParamTag.resolveUrl(MailParamTag.java:181) at coldfusion.tagext.net.MailParamTag.setFile(MailParamTag.java:91) at cfcommsEmailer2ecfc1325954500$funcONINCOMINGMESSAGE.runFunction(\\Dcdb01\websites\dev\sit e2\gateway\commsEmailer.cfc:100) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:348) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:258) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:211) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:173) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:192) at coldfusion.filter.EventComponentFilter.invoke(EventComponentFilter.java:67) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:203) at coldfusion.filter.EventRequestMonitorFilter.invoke(EventRequestMonitorFilter.java:46) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.eventgateway.EventProxy.invokeComponent(EventProxy.java:52) at coldfusion.eventgateway.EventRequestHandler.invokeCFC(EventRequestHandler.java:165) at coldfusion.eventgateway.EventRequestHandler.processRequest(EventRequestHandler.java:102) at coldfusion.eventgateway.EventRequestDispatcher$Task.run(EventRequestDispatcher.java:121) at coldfusion.util.SimpleWorkerThread.run(SimpleThreadPool.java:214)