Jump to content

"mail merge" printing using browser


kk2628

Recommended Posts

Hi,

 

I am new to this forum and not sure if this is the right place to seek solution to my problem, if not, please kindly let me know the right topic to post.

 

I have a requirement to enable user to print their particulars like name, age, etc. when they want to print out a standard invitation letter (which is a html page). They should have a choice to upload a personalinfo.csv file so that when they submit to print the page, each invitation letter can be printed with their respective personal information printed on the letter. It is like a mail merge function available in most of the word processor application, but this time is on the web.

 

I have googled and found the below which is the closest to meet the requirement but I am not still not able to make it work.

 

Source of mailMerge.php

<html>

<head>

<title>Mailing List</title>

</head>

<body>

<form>

 

 

<?

//Simple Mail merge

//presumes tab-delimmited file called maillist.dat

 

$theData = file("maillist.dat");

 

 

 

foreach($theData as $line){

$line = rtrim($line);

print "<h3>$line</h3>";

list($name, $email) = split("\t", $line);

print "Name: $name";

 

$message = <<<HERE

TO: $email:

Dear $name:

 

Thanks for being a part of the spam afficianado forum. You asked to

be notified whenever a new recipe was posted. Be sure to check our web

site for the delicious 'spam flambe with white sauce and cherries' recipe.

 

Sincerely,

 

Sam Spam,

Host of Spam Afficianados.

 

HERE;

 

 

print "<pre>$message</pre>";

 

} // end foreach

 

 

 

 

?>

</body>

</html>

 

 

 

 

Appreciate any advise.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.