nice workaround ;-) but how about this: save your rtf-file and use it as a "template" with unique "place-holders" (e.g. your rtf-part %yourUniqueDateField% next rtf-part). use preg-replace() and replace your "place-holders" with your content. save your copy or mail it.
ciao SVEN "George Pitcher" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Hi all, > > I had a requirement to produce neat Word documents to send as email > attachments. I looked at the COM method but couldn't get it to work (didn't > really try that hard though). Anyhow, I tried another method which procuces > exactly what I need. > > Firstly, create the document shell in Word (this will possibly work in other > formats but not tested here), leaving a space for any 'variable' content. > Save the document as an RTF file (Rich Text Format). > > Open the RTF file in Notepad (or similar) and find the first part of your > file (beginning of file to where the first variable goes in) and save that > as a text file (filename1.txt), Then find the part between the first and > second variables and save as 'filename2.txt' repeating until you have the > whole rtf file saved as a collection of txt files. > > Store them on your server. > > In your php script do the following: > > $name="Stephen"; // my example > $fp = "c:\\inetpub\\wwwroot\\mydir\\"; > $fn1 = file_get_contents("letter1.txt"); > $fn2 = file_get_contents("letter2.txt"); > $fn3 = file_get_contents("letter3.txt"); > > $filename = "letter.doc"; > $content = $fn1; > $content.= date("d, M Y"); > $content.= $fn2; > $content.= $name; > $content.= $fn3; > if (!$fp = fopen($filename, 'w')) { > print "Cannot open file ($filename)"; > exit; > } > if (!fwrite($fp, $content)) { > print "Cannot write to file ($filename)"; > exit; > } > fclose($fp); > > I use phpmailer and I've tested the attachment part and it works fine. > > It might not suit every requirement but its a quick way to get letters > formatted in word. > > Hope this helps someone. > > George in Oxford > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php