473,415 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,415 software developers and data experts.

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

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
6 3650
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bruce | last post by:
Has anyone tried sending web pages containing javascript to another user also using Outlook Express? Mine don't work on the other end - although I'm not sure if this is because they don't have...
3
by: scott | last post by:
Anyone have a link to syntax that could create an outlook vcard file format? all examples i find are for doing it inside outlook with .net. i'm just looking for an ASP solution.
4
by: lauren quantrell | last post by:
Is there a way to open the MS Outlook address book using VBA and then be able to do something with the return value? I want users to click an icon to open the Outlook address book then when an...
3
by: Jyothi | last post by:
Hi All, Thanks for ur reply for my previous postings. I have a question. I wanted to show the outlook inbox in a window with minimal options like send,delete,reply,forward,replytoall,new...
1
by: DotNetJunkies User | last post by:
I wonder if someone could tell me how to open outlook by code and add a ny contact folder, and insert a email account /Mathias --- Posted using Wimdows.net NntpNews Component - Post Made...
2
by: HvG | last post by:
I'm sure this is a trivial question, but I cannot create an Outlook Object from a WebForm app, but can from a console app. or a Windows app. My COM knowledge is very poor sorry. ...
1
by: Michele | last post by:
Hi, I need to send the same Email to different people. I'm using Outlook XP and VB.Net. I tryed with the following code: Dim oOutL As Outlook.Application Dim oMail As Outlook._MailItem oOutL...
2
by: John | last post by:
Hi I am trying to find the way to create an email in outlook. I am using the code given at the end. It works fine the first time but calling the code second time gives the following error; ...
4
by: Nicole | last post by:
I found this code below to use to send emails using VB with Outlook. However, it gives these errors. 'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.