By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,967 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,967 IT Pros & Developers. It's quick & easy.

fyi - combination of outlook and php - create stationery for MS outlook using PHP engine ;-)

P: n/a
Hi Folk

Some of my clients asked me to create "fancy emails" for them (aka html
formatted emails).

I know how to make a nice html document, but I had trouble creating a simple
way to provide the document to my clients so that they could use it to.

I know most of them use Outlook XP or Outlook 2003, so what I created was a
page that creates a Visual Basic script that, when saved to the desktop and
clicked (run), opens a message in outlook using the html provided.

To see this in action, please go to :

http://www.rakau.com/station/index.php

I would love to have some feedback.

Nicolaas

Mar 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Worked on:
Operating System: Windows 2000 Professional (5.0, Build 2195) Service
Pack 4
Language: German (Regional Setting: German)
MS Office Word 2003 (11.5604.5606)

Feedback:
Subject, and `to:' e-mail address will be fine

Mar 22 '06 #2

P: n/a
windandwaves wrote:
Hi Folk

Some of my clients asked me to create "fancy emails" for them (aka html
formatted emails).

I know how to make a nice html document, but I had trouble creating a simple
way to provide the document to my clients so that they could use it to.

I know most of them use Outlook XP or Outlook 2003, so what I created was a
page that creates a Visual Basic script that, when saved to the desktop and
clicked (run), opens a message in outlook using the html provided.

To see this in action, please go to :

http://www.rakau.com/station/index.php

I would love to have some feedback.
Nicolaas



So - what does this have to do with PHP, and why are you posting this in
a PHP newsgroup?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 22 '06 #3

P: n/a
Jerry Stuckle wrote:
[....]

So - what does this have to do with PHP, and why are you posting this
in a PHP newsgroup?


Because ultimately it is a PHP application. The code is below. It may give
some people some ideas or help someone I thought (obviously more aimed at
beginners):

<?php
if($_POST["submit"]) {
//clean input
if(!$_POST["filename"]) {
$_POST["filename"] = "test";
}
$filename = alpha_numeric_make_one($_POST["filename"]).'.vbs';
$i = 0;
while(file_exists($filename)){
$i++;
$filename = $i.'_'.$filename;
}
if(!$_POST["html"]) {
$_POST["html"] = example_text();
}
$data = createvbscript($_POST["html"]);
$length = strlen($data);
if($length > (1024 * 4)) {
die("file is too large - sorry");
}
//create file
if (!$handle = fopen($filename, 'w+')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $data) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
fclose($handle);
//force download
@ob_end_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-Disposition: attachment; filename="'.$filename.'"' );
header("Content-Type: application/force-download");
// Length required for Internet Explorer
header("Content-Length: ".$length);
echo $data;
flush();
@ob_flush();
}
else {
$v = '<h1>create outlook stationery</h1>
<div id="explanation">
<p>This page creates a macro from an html file. The macro can be used by
people with Windows XP and Microsoft Office XP to write <i>fancy emails</i>.
This page may particularly useful for IT professionals with clients who
are interested in sending <i>html formatted</i> emails.</p>
<p>Please copy an html file below, keeping the following in mind:</p>
<ul>
<li>keep it simple</li>
<li>place all styles in elements (e.g. write <i>&lt;p style=&quot;margin:
10px;&quot;&gt;</i>)</li>
<li>do not put styles in the header or the body tag, because these are
most likely to be removed by mail programs</li>
<li>make absolute references to external (image) files (e.g.
<i>http://www.mysite.com/logo.gif</i> rather than <i>logo.gif</i>)</li>
<li><a href="http://validator.w3.org">validate</a> your file before
submitting it</li>
<li>do not use lightly coloured fonts (e.g. white) or dark backgrounds
(e.g. black), because the person may reply without the background colour or
without the font colour. </li>
<li><b>only works for people with Windows XP and MS Office XP</b> -
please let me know if you need a different format and I will endeavour to
create it.</li>
<li>to see an example, just enter a filename and leave the html field
blank.</li>
<li>the maximum file size for this example is 2Kb.</li>

</ul>
</div>
<h1>enter details below</h1>
<div id="former">
<form method="post" action="index.php">
<p>
html document: <br />
<textarea cols="50" rows="20" name="html"></textarea>
<br />file name:<input name="filename" />
<br /><input type="submit" name="submit" value="create VB Script macro
for fancy formatted email" id="submit" />
</p>
</form>
</div>
<h1>example html document</h1>
<div id="sampler">
<pre>'.htmlentities(example_text()).'</pre>
</div>
';
}
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>create outlook stationery</title>
<link rel="icon" href="http://www.sunnysideup.co.nz/i/favicon.ico"
type="image/ico" />
<link rel="shortcut icon"
href="http://www.sunnysideup.co.nz/i/favicon.ico" />
<link href="s/s.css" rel="stylesheet" type="text/css" />
<meta name="keywords" content="create outlook stationery" />
<meta name="description" content="create outlook stationery" />
</head>
<body>
<div id="title">
<img src="i/logo.gif" alt="Sunny Side Up - Stationery it" title="Sunny
Side Up - Stationery it" width="720" height="140" />
</div>
'.$v.'
</body>
</html>';
echo $html;

function createvbscript($s) {
$s = str_replace('"', '" & chr(34) & "', $s);
$s = str_replace("\r", ' ', $s);
$s = str_replace("\n", ' ', $s);
$s = str_replace(' ', ' ', $s);
$v = '
Dim theApp
Set theApp = WScript.CreateObject("Outlook.Application")
CreateHTMLMail(theApp)

Public Sub CreateHTMLMail(olapp)
Dim objMail
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.BodyFormat = 2
.HTMLBody = "'.$s.'"
.Display
End With
End Sub';

return $v;

}
function alpha_numeric_make_one ($s) {
//replaces all non alpha-numeric entries
if($s) {
$s = eregi_replace("[^[:alnum:]]", " ", $s);
$s = trim(eregi_replace(" +", "", $s)); //removes excess spaces
return $s;
}
return false;
}

function example_text() {
return '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<title>sexy message from me</title>
</head>
<body style="background-color: #D4D0C8; padding: 0px; margin: 0px auto 0px
auto;">
<div id="container" style="background-color: #D4D0C8; padding: 0px;
margin-left: auto; margin-right: auto;" align="center">
<div id="main" style="background-color: white; margin: 0px auto 0px
auto; width: 380px; padding: 20px;" align="Center">
<p style="padding: 0px; margin: 0px; text-align: center; color:
#333333; ">
<br>
double-click to edit
<br>
</p>
</div>
</div>
</body>
</html>';
}

?>
Mar 22 '06 #4

P: n/a
Johannes Matjeschk wrote:
Worked on:
Operating System: Windows 2000 Professional (5.0, Build 2195) Service
Pack 4
Language: German (Regional Setting: German)
MS Office Word 2003 (11.5604.5606)

Feedback:
Subject, and `to:' e-mail address will be fine


Thank you for your feedback. What exactly do you mean?
Mar 22 '06 #5

P: n/a
windandwaves wrote:
Jerry Stuckle wrote:
[....]
So - what does this have to do with PHP, and why are you posting this
in a PHP newsgroup?

Because ultimately it is a PHP application. The code is below. It may give
some people some ideas or help someone I thought (obviously more aimed at
beginners):


<snip>

OK, and your PHP question is...?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 22 '06 #6

P: n/a
Jerry Stuckle wrote:
windandwaves wrote:
Jerry Stuckle wrote:
[....]
So - what does this have to do with PHP, and why are you posting
this in a PHP newsgroup?

Because ultimately it is a PHP application. The code is below. It
may give some people some ideas or help someone I thought (obviously
more aimed at beginners):


<snip>

OK, and your PHP question is...?


It was not really a question, but as I understand it, a message board can
also be used to make announcements or share ideas, not just ask questions.
i ask a lot of questions, but when I make something I like to share it,
because I want to be stay ahead of the karma police ;-) I have had so many
awesome responses over the last year, that I would love to add something
myself.

I try to make my subject lines as informative as possible so that people can
ignore it if they have no interest.
Nicolaas

Mar 22 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.