Extracting Email addresses out of MS Outlook's email format
Outlook "name  email@domain.com)" format could be trouble  

Say you have a email list in Outlook you want to use somewhere else (e.g. AOL, Yahoo).  You may have problems because Outlook uses a format incompatible with other email programs (e.g. AOL, Yahoo).  Try to "cut & paste" the list from the "To: " in your MS Outlook email, and you'll end up with not just with email addresses, but also names.  Outlook places the person's name before the email. 

Example: "Joe Dirt (joedirt@yahoo.com); Jack Jonsen (jj@hotmail.com)"

This is a problem if you wish to copy addresses into another email program (e.g. AOL, Yahoo) which does not accept MS Outlook's format.


Steps to run the code:

1. Get a computer with a Perl scripting engine
2. Save a text file, name it "everyone.txt," with email addresses in it in the "Joe Dirt (joedirt@yahoo.com)" format. Semicolons as the delimiter.
3. Cut and paste the code below.
4. Save the code file as "emailsplit.pl"
5. For Linux, "Chmod 744" so you can execute the file.
6. Place the "everyone.txt" file in the same directory as the code file.
7. For Linux, type "./emailsplit.pl" to run the program.
8. Cut and paste the "clean" addresses to wherever you want.

The Code  

#!/usr/bin/perl -w
#Author: dcregal
#Date created: 3/31/2004
#Date modified: 3/31/2004
#File: emailsplit.pl

$file = "everyone.txt";
#grab some data
$emailaddresses = `cat $file`;
#Let's break apart EMAILADDYS into a usable array.
@emailaddys = split(';', $emailaddresses);
#For Debuggin: print @emailaddys;
#print "Orig: " . $emailaddys[$k] . "\n";
#Get rid of the names caused from exporting from Outlook.
$emailaddys[$k] =~ /\((.*@.*)\)/;
#If the email had parenthesis around it, use "clean" version.
$emailclean[$k] = $1 . "; ";
#Else, ff blank, use the original. Which probably was just
# an email address to begin with, (i.e. no parenthesis).
if($emailclean[$k] eq "; ") {
print "Using Original.\n";
$emailclean[$k] = $emailaddys[$k] . "; ";
#For Debugging: print "Clean: " . $emailclean[$k] . "\n\n";
print @emailclean;



Please email corrections or comments to: webmaster@techborder.com Last updated: 3/31/2004
Home | Linux | Projects | Resumé | Photos | My Life