Adding attachments to cfmail

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Adding attachments to cfmail

    I have a form that allows a user to send an email to a list with the option of
    adding an attachment. The action page uploads the file, using cffile, to a temp
    diectory and then creates the email and adds the attachment using cfmail and
    cfmailparam. I then used cffile to delete the file. A problem arose because the
    file was deleted before the email was sent. I then used the following code to
    delete all files in the temp directory before uploading the new file.
    <cfdirectory
    directory='#REQUEST.Site_DirectoryPath#brd_dynamic/email/attachments/'
    name='q'> <cfoutput query='q'> <cfif q.type eq 'file' and dateDiff('h',
    createodbcdate(q.datelastmodified), now()) GT 0> <cffile action='delete'
    file='#REQUEST.Site_DirectoryPath#brd_dynamic/email/attachments/#q.name#'>
    </cfif> </cfoutput> I get the following error: The value 'Thursday, March
    24, 2005 2:40:33 PM EST' could not be converted to a date. Any ideas?

    mfasis Guest

  2. Similar Questions and Discussions

    1. CFMAIL - Unicode filename for attachments
      Hello again PaulH, I am hoping you can give me some advice about this. I have the charset attribute set to "utf-8". See attached code. I've...
    2. Dynamically Including CFMAIL Attachments
      Please help! I am wrting an app that uses CFMAIL, and need to dynamically attach files based on locations and filenames stored in a table. I...
    3. Adding Multiple Attachments to CFMAIL
      Is there a way to add multiple mime files using <CFMAIL>? Here is the code I am using, but it doesn't work. When I comment out the second mime...
    4. 2 attachments in CFMail
      I think the summary says it all. Anyone know the syntax for this? Assuming it is possible of course :-)
    5. cfmail - Attribute validation error for tag CFMAIL.
      I'm getting the error ' Attribute validation error for tag CFMAIL.' on the code below. All its doing is outputting a text string to the TO: field. ...
  3. #2

    Default Re: Adding attachments to cfmail


    You probably want to get rid of the createodbcdate() call in there.


    blewis Guest

  4. #3

    Default Re: Adding attachments to cfmail

    Sorry, In my original code the creatodbcdate() was not there. I was just
    trying anything to see if it worked. <cfoutput query='q'> <cfif q.type eq
    'file' and dateDiff('h', q.datelastmodified, now()) GT 0> <cffile
    action='delete'
    file='#REQUEST.Site_DirectoryPath#brd_dynamic/email/attachments/#q.name#'>
    </cfif> </cfoutput>

    mfasis Guest

  5. #4

    Default Re: Adding attachments to cfmail

    Are you using CF 7? This seems to run just fine for me on CF 6.1. Although I
    did hard code my path instead of using a variable. You may want to try that
    just to see if they might be something wrong with the variables.

    Mike Greider Guest

  6. #5

    Default Re: Adding attachments to cfmail

    Hi

    Try using ParseDateTime, it will convert to standard Date/Time format so you can do the date comparison.

    #dateDiff("h", ParseDateTime(q.datelastmodified), now()) #

    HTH

    Zoe
    zoeski80 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139