home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / email / send.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.4 KB  |  51 lines

  1. <CFSET NewBody = Form.MessageBody>
  2.  
  3. <!--- Create main temp directory if it doesn't already exist --->
  4. <CFSET TempDir = GetTempDirectory() & "CrazyCab\">
  5. <CFTRY>
  6.     <CFDIRECTORY ACTION="CREATE" DIRECTORY="#TempDir#">
  7.     <CFCATCH TYPE="ANY">
  8.     </CFCATCH>
  9. </CFTRY>
  10.  
  11. <!--- Create outbound temp directory if it doesn't already exist --->
  12. <CFSET AttachDir = TempDir & "outbound\">
  13. <CFTRY>
  14.     <CFDIRECTORY ACTION="CREATE" DIRECTORY="#AttachDir#">
  15.     <CFCATCH TYPE="ANY">
  16.     </CFCATCH>
  17. </CFTRY>
  18.  
  19. <!--- Word-wrap the text that will be sent --->
  20. <CF_Wrap VARIABLE="NewBody" WIDTH="80">
  21.  
  22. <!--- If this message has a file attachment... --->
  23. <CFIF Form.AttachFile NEQ "">
  24.  
  25.     <!--- ...save the file to the server... --->
  26.     <CFFILE ACTION="UPLOAD"
  27.         FILEFIELD="AttachFile"
  28.         DESTINATION="#AttachDir#"
  29.         NAMECONFLICT="OVERWRITE">
  30.  
  31.     <!--- ...and send the message with file attached... --->
  32.     <CFMAIL FROM="#Session.Email#"
  33.         TO="#Form.To#"
  34.         CC="#Form.cc#"
  35.         SUBJECT="#Form.Subject#"
  36.         SERVER="#Session.SMTPserver#"
  37.         MIMEATTACH="#AttachDir##File.ServerFile#">#NewBody#</CFMAIL>
  38.  
  39. <!--- ...otherwise... --->
  40. <CFELSE>
  41.  
  42.     <!--- ...just send the text with no attachment. --->
  43.     <CFMAIL FROM="#Session.Email#"
  44.         TO="#Form.To#"
  45.         CC="#Form.cc#"
  46.         SUBJECT="#Form.Subject#"
  47.         SERVER="#Session.SMTPserver#">#NewBody#</CFMAIL>
  48.  
  49. </CFIF>
  50.  
  51. <CFLOCATION URL="messagelist.cfm" ADDTOKEN="NO">