Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate attachment in CFMAIL, please help

Status
Not open for further replies.

kuolung

Programmer
Sep 2, 1999
51
US
I know that in CFMAIL you can send attachment for file which already pre existed.
however, how to make CFMAIL content as an attachment (for example as html file) and as the same time, send out email???? Any help would be apprciated. Thanks.
 
HI,

I've never tested this but in theory you should be able to use <CFFILE Action=&quot;write&quot;
File=&quot;C:\temp\temp.html&quot;
output=&quot; #MYHTMLCONTENT# &quot;>

to create the HTML file then attatch it with <CFMAIL ...

The only problem I can see with this is picking a file name. depending on how many people could be using this application you might need to make a filename system like:

temp#CFID#.html

so that each person would have there own temp html file to Attatch.

Hope it helps.
 
tlhawkins,
thanks for replying. However, i'm lost here. for example, this is what i have:

<cfmail to=&quot;#emailQry.email#&quot;
from=&quot;#v_from#&quot;
subject=&quot;#v_subject#&quot;
server=&quot;#smtp_server#&quot;
type=&quot;HTML&quot;>

Hello <b>#emailQry.email#</b><br>

<p>This is your class schedule</p>:
<table>
</table>.....
.....

</cfmail>

where do i put CFFILE tag?? I was guessing it should be out the CFMAIL,
what about the output content, how do specify that #MYHTMLCONTEN# variable that you gave in your example???

pls help me out. thanks.


 
I think I understand the question.

I shouldn't have used #MYHTMLCONTENT#

Do this:

<CFFILE Action=&quot;Append&quot;
File=&quot;d:\http\pb-solutions_com\travs\test1.html&quot;
output=&quot;<TABLE border=1
cellpadding=0
cellspacing=0>&quot;>

<CFOUTPUT query=&quot;MyQuery&quot;>

<CFFILE Action=&quot;Append&quot;
File=&quot;d:\http\mydir\temp.html&quot;
output=&quot;<TR> <td> #QUeryData#, #QueryData2#</td> </tr>&quot;

>
</CFOUTPUT>

<CFFILE Action=&quot;Append&quot;
File=&quot;d:\http\pb-solutions_com\travs\test1.html&quot;
output=&quot;</Table>&quot;>

That will do a simple table with your Query Data. It's a little anoying but it works.

Just be careful of quotes inside the output =&quot; &quot; string, change them to ' .

The idea is to put the <CFFILE action=&quot;Append&quot; ...> Wherever you would have put the formatting for the data that you would have put on the screen. Put the formatting and data instead into the output = &quot; ...&quot; string.

This works for me. I hope I got the right question this time. :)

 
1) If you uses Coldfusion server 4, you can make only one attachment. Use the 'mimeAttach' attribute of CFMAIL

<cfmail to=&quot;#emailQry.email#&quot;
from=&quot;#v_from#&quot;
subject=&quot;#v_subject#&quot;
server=&quot;#smtp_server#&quot;
type=&quot;HTML&quot;
mimeAttach=&quot;C:\temp\temp.html&quot;>

Hello <b>#emailQry.email#</b><br>

<p>This is your class schedule</p>:
<table>
</table>.....
.....

</cfmail>


2) If you uses Coldfusion server 4.5, you can make several attachments. Use the new tag <CFMAILPARAM FILE=&quot;file_name&quot;>.

<cfmail to=&quot;#emailQry.email#&quot;
from=&quot;#v_from#&quot;
subject=&quot;#v_subject#&quot;
server=&quot;#smtp_server#&quot;
type=&quot;HTML&quot;>

<cfmailparam file=&quot;C:\temp\temp.html&quot;>
<cfmailparam file=&quot;C:\temp\temp2.html&quot;>

Hello <b>#emailQry.email#</b><br>

<p>This is your class schedule</p>:
<table>
</table>.....
.....

</cfmail>
 
You should also check out the CFX_iMSMAIL tag here ...
In my opinion, a much better tag.

With it you have complete control over all headers which would allow you to do something like this ...

<!--- convert message to base64 first --->
<cfset CRLF=CHR(13)&CHR(10)>
<cfset MaxWidthPos=72>
<cfset htmlattach=ToBase64(html)>

<cfloop condition=&quot;#MaxWidthPos# LTE #len(htmlattach)#&quot;>
<cfset htmlattach=insert(CRLF,htmlattach,MaxWidthPos)>
<cfset MaxWidthPos=MaxWidthPos+74>
</cfloop>

then in your message header ...

...
Content-Type: multipart/mixed; boundary=&quot;----Next_Part&quot;
...
------Next_Part
Content type: text/html
charset=us-ascii
Content-Transfer-Encoding: 7bit

#html#

------Next_Part
Content-Type: text/html;
name=&quot;WhateverYouWantToCallIt.html&quot;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=&quot;WhateverYouWantToCallIt.html&quot;

#htmlattach#

------Next_Part--

HTH,
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top