home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / exampleapps / email / send.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.6 KB  |  60 lines

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