Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cmcconkey

macrumors 6502
Original poster
Nov 22, 2005
313
5
Rocky Face, GA
The owner of the company that I work for has asked me if there is a way to create a signature that would look something like this:
Example.jpg


But with a random photo of one of our products pop up in the box to the right that would link out to the products part of our website and then the web address to link to the main page of our website.

I am pretty sure that I have seen this done but I am pretty well clueless on how to do this. Any help would be greatly appreciated.

Thanks

Christopher
 
For everyday emails?

You can do this with template emails and some PHP. We add graphics and images with HTML on some of our clients invoices that pulls dynamic information via the database, not images but it's the same concept. But it's not like you can just choose a setting in Outlook and create a sig that randomly generates a product and a URL. Not to mention, you'd have to send through a special gui every time to it generates the proper sever side code.
 
It is not overly complicated, actually. The email message is just an HTML page, so you just need to set up the signature as you would a piece of a regular HTML page. For instance, you might make a div, put the signature text inside it, and float an image on the right. Or, you might use tables... but those are a bit bulky, and they have a bad reputation. However, they may be the way to go if you need to position things precisely.

To make the image random, simply make a PHP (or other) page on the website called featuredimage.php (or whatever you want to call it), and make it output a random picture. The output of a specific file can be accomplished with the readfile function in PHP, which basically reads in a specific file and writes it directly to the output. You'd also need to specify a content-type header so the browser (email client) knows what kind of file is being sent. This can be done with PHP's header function.

Finally, you'd set the src attribute of the image in the email to the complete absolute url for featuredimage.php (or whatever you named it). For instance:
HTML:
<img src = "http://my-website.com/featuredimage.php" alt = "Featured Product" />

An example PHP file:
PHP:
<?php
// This is an example image

//a list of files
$files = array();
$files[0] = "images/product1.jpg";
$files[1] = "images/product2.jpg";
$files[2] = "images/product3.jpg";

//pick one randomly
$random_number = rand(0, count($files) - 1);
$random_file = $files[$random_number];

//Output a header
header("content-type: image/jpeg");

//Output the file
readfile($random_file);
?>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.