Skip navigation
Currently Being Moderated

cfmailparam file argument doesnt work within events

May 28, 2006 9:15 AM

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(\\Dcd b01\websites\dev\site2\gateway\commsEmailer.cfc:100) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:348) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMetho d.java:258) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.ja va: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.ja va:67) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:203 ) at coldfusion.filter.EventRequestMonitorFilter.invoke(EventRequestMonito rFilter.java:46) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePers istenceFilter.java:28) 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(EventRequestHan dler.java:165) at coldfusion.eventgateway.EventRequestHandler.processRequest(EventReque stHandler.java:102) at coldfusion.eventgateway.EventRequestDispatcher$Task.run(EventRequestD ispatcher.java:121) at coldfusion.util.SimpleWorkerThread.run(SimpleThreadPool.java:214)
 
Replies
  • Currently Being Moderated
    May 29, 2006 12:20 PM   in reply to Gary__F
    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?

    Indeed. However, I do believe there is a plausible reason for the error message. My hypothesis is that you're using the Developer Edition of MX7.x, which is allowed only one thread for processing Gateway events. I suspect that Coldfusion requires at least 2 threads to send an e-mail containing an attachment. Just a wild guess.

     
    |
    Mark as:
  • Currently Being Moderated
    May 29, 2006 10:42 PM   in reply to BKBK
    I'm running the full Enterprise edition
    It's back to the mill again. I've tested the code with all possible combinations of attributes for cfmailparam, including setting the values in the calling page, changing location, permissions, etc. of the attached file. No luck. Like you, I got the error "String index out of range: -1" every time.

    In my opinion, the first five lines of your stack trace suggest Coldfusion is having problems. It appears that the CFML-to-Java conversion of cfmailparam doesn't work within the Gateway framework.

     
    |
    Mark as:
  • Currently Being Moderated
    May 30, 2006 2:19 AM   in reply to Gary__F
    Gary_F,
    To report a bug, follow the Send Feedback link at the bottom of this page. As far as Coldfusion is concerned, men don't come in higher places than Mr. Ben Forta (ben@forta.com). Write him.
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 3, 2006 2:55 AM   in reply to Gary__F
    What a relief. It redeems Coldfusion that it is possible to send e-mail attachments via Event Gateways, albeit by means of a workaround.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 12, 2006 9:12 AM   in reply to BKBK
    Does anyone know if this bug has been resolved in a hot fix or anything. I am looking around on the adobe site for a list of bugs etc and I cannot find it for the life of me.
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 20, 2006 6:59 AM   in reply to Gary__F
    Gary, yeah you are right, it would save us to much valuable time!

    Ok, but seriously, CF is great when it works.....but when it does not want to cooperate....

    I have run into another issue now. I can send a simple html file as an attachment (using abs URL) but if I try to attach more than 1 files it take about 75 minutes to send 300 emails. If I attach a pdf file nothing gets sent. All the messages just sit in the spool.

    Has anyone else seen this issue or have any ideas?
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 20, 2006 7:06 AM   in reply to Gary__F
    Ok here is a little more info I have. I see the following in the mail log.

    IOException while sending message; nested exception is: java.net.SocketException: Software caused connection abort: socket write error

    and

    421 Command timeout, closing transmission channel
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points