Has anyone imported Outlook folders and mail into Evolution? I'm using Outlook 2k and Evolution 1.0.2. Thanks, Tom Tom Nielsen Neuro Logic Systems 805.389.5435 x18 www.neuro-logic.com
Are you using Outlook to connect to an Exchange server? If yes, do you have IMAP running on it? This will make it very easy, as Evolution talks IMAP - that's how I connect to my company's Exchange server. If it's Exchange 2000, you could even get your employer to pay for Ximian Connector to make Evolution a full Exchange client...
Has anyone imported Outlook folders and mail into Evolution? I'm using Outlook 2k and Evolution 1.0.2. -- James Ogley, Unix Systems Administrator, Pinnacle Insurance Plc james.ogley@pinnacle.co.uk www.pinnacle.co.uk +44 (0) 20 8731 3619 Using Free Software since 1994, running GNU/Linux (SuSE 8.0) Updated GNOME RPMs for SuSE Linux: www.usr-local-bin.org
*********************************************************************** CONFIDENTIALITY. This e-mail and any attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose, or store or copy the information in any medium. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Pinnacle Insurance Plc. If you have received this e-mail in error please immediately notify our Helpdesk on +44 (0) 20 8207 9555. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************
On Thu, 2002-05-23 at 08:40, Tom Nielsen wrote:
Has anyone imported Outlook folders and mail into Evolution? I'm using Outlook 2k and Evolution 1.0.2.
Thanks, Tom
Tom Nielsen Neuro Logic Systems 805.389.5435 x18 www.neuro-logic.com
Hi Tom, When I switched to Linux I successfully converted my .pst files to mbox format, together with my Outlook contacts and imported them into Evolution. It's a fairly convoluted process, but it worked for me. If you have a strong stomach (or masochistic tendencies), make yourself a large pot of coffee (or something stronger) and give this a try: *********************************************************************** Mozilla under Windows can access the .pst Outlook files because it can use the Windows MAPI.DLL library. Using MAPI.DLL is the only way to access .pst files, and it can be used under a Windows operating system. To start importing your Outlook mail to Evolution, run Mozilla Mail on Windows and select the Importer to begin: File > Import Then select the .pst file that you wish to import Mail from Outlook. Once Mozilla has imported all your mail, reboot your computer into Linux. Mount your Windows partition in Linux and run Evolution to begin importing your mail. Select the Importer from the File menu to start importing: File > Import File... Set the file type to "MBox (mbox)" and click on [Browse] to select the file containing mail you want to import. If you are the only user on Windows, the mail files will be stored in /mnt/windows/c/Windows/Application Data/Mozilla/Profiles/default/XXXX/Mail/imported.mail/ where /mnt/windows/c/ is your windows partition mount point and XXXX is some collection of numbers and digits ending in .slt. If there is more than one user, the file will be in /mnt/windows/c/windows/Profiles/USERNAME/XXXX/ Mail/imported.mail/ where USERNAME is your Windows username. For each mail folder in Outlook, Mozilla will convert the folder into one mbox file. To import all your mail, import all the files into Evolution, that do not a .msf extension. ALTERNATIVELY You may want to get the conversion program libpst-0.3beta1.tgz which can be downloaded from http://sourceforge.net/projects/ol2mbox/ ************************************************************************** To import your contacts from Outlook you will need to export all of your contact folders in Outlook to a .csv file. To do this in Outlook: Click on File > Import and Export.... Choose "Export to a file" and click [Next]. For the file type choose "Comma Separated Values (DOS)". Click [Next]. If you have sub-folders under "Contacts" each sub-folder must be exported separately. Name the exported files "same_as_outlook_folder.csv" (sans quotes and keep a note of the path). Click [Next]. Click [Finish]. To import contacts.csv into Evolution you will have to run each .csv file through the attached Perl script (csv2vcard.pl). Download csv2vcard.pl into your home directory and make the script executable by running this command: $ chmod +x ~/csv2vcard.pl Run this script to convert contacts.csv to contacts.vcf: $ ./csv2vcard.pl contacts.csv contacts.vcf Once you have contacts.vcf, you can import it into Evolution by: Clicking File > Import. Click [Next]. Click on "Import from a single file" Click [Next] again. For file type choose "VCard...". Click [Browse] and select your file. Click [Next] then [Import]. ************************************************************************** Hope this helps and good luck. Dave
I see what you mean!! I just imported 1 of 50ish folders and it took me about 5 minutes. Yuck!! I guess I have to do this one by one to make sure they transfer ok. ??? It's a small price to pay...I guess. Tom On Thu, 2002-05-23 at 22:03, Dave Barton wrote:
On Thu, 2002-05-23 at 08:40, Tom Nielsen wrote:
Has anyone imported Outlook folders and mail into Evolution? I'm using Outlook 2k and Evolution 1.0.2.
Thanks, Tom
Tom Nielsen Neuro Logic Systems 805.389.5435 x18 www.neuro-logic.com
Hi Tom,
When I switched to Linux I successfully converted my .pst files to mbox format, together with my Outlook contacts and imported them into Evolution. It's a fairly convoluted process, but it worked for me.
If you have a strong stomach (or masochistic tendencies), make yourself a large pot of coffee (or something stronger) and give this a try:
***********************************************************************
Mozilla under Windows can access the .pst Outlook files because it can use the Windows MAPI.DLL library. Using MAPI.DLL is the only way to access .pst files, and it can be used under a Windows operating system.
To start importing your Outlook mail to Evolution, run Mozilla Mail on Windows and select the Importer to begin:
File > Import
Then select the .pst file that you wish to import Mail from Outlook. Once Mozilla has imported all your mail, reboot your computer into Linux.
Mount your Windows partition in Linux and run Evolution to begin importing your mail. Select the Importer from the File menu to start importing:
File > Import File...
Set the file type to "MBox (mbox)" and click on [Browse] to select the file containing mail you want to import.
If you are the only user on Windows, the mail files will be stored in /mnt/windows/c/Windows/Application Data/Mozilla/Profiles/default/XXXX/Mail/imported.mail/ where /mnt/windows/c/ is your windows partition mount point and XXXX is some collection of numbers and digits ending in .slt.
If there is more than one user, the file will be in /mnt/windows/c/windows/Profiles/USERNAME/XXXX/ Mail/imported.mail/ where USERNAME is your Windows username.
For each mail folder in Outlook, Mozilla will convert the folder into one mbox file. To import all your mail, import all the files into Evolution, that do not a .msf extension.
ALTERNATIVELY
You may want to get the conversion program libpst-0.3beta1.tgz which can be downloaded from http://sourceforge.net/projects/ol2mbox/
**************************************************************************
To import your contacts from Outlook you will need to export all of your contact folders in Outlook to a .csv file. To do this in Outlook:
Click on File > Import and Export.... Choose "Export to a file" and click [Next]. For the file type choose "Comma Separated Values (DOS)". Click [Next]. If you have sub-folders under "Contacts" each sub-folder must be exported separately. Name the exported files "same_as_outlook_folder.csv" (sans quotes and keep a note of the path). Click [Next]. Click [Finish].
To import contacts.csv into Evolution you will have to run each .csv file through the attached Perl script (csv2vcard.pl). Download csv2vcard.pl into your home directory and make the script executable by running this command:
$ chmod +x ~/csv2vcard.pl
Run this script to convert contacts.csv to contacts.vcf:
$ ./csv2vcard.pl contacts.csv contacts.vcf
Once you have contacts.vcf, you can import it into Evolution by:
Clicking File > Import. Click [Next]. Click on "Import from a single file" Click [Next] again. For file type choose "VCard...". Click [Browse] and select your file. Click [Next] then [Import].
**************************************************************************
Hope this helps and good luck.
Dave
----
#!/usr/bin/perl -w # # csv2vcard.pl # # Copyright (C) 2001 Ximian, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # Authors # Michael MacDonald
# Chris Lahey # # ChangeLog: # # 2001-12-12 Michael MacDonald # Hello World! # use strict; use diagnostics; use Text::ParseWords; sub usage { print STDERR << "--EndOfUsage";
Takes a CSV-formatted list of contacts from Outlook and attempts to convert it into a list of VCards suitable for import into Evolution.
Usage: $0 [infile outfile]
--EndOfUsage
exit; }
sub is_recognized_format { my $line = shift;
# Making some assumptions here... Prolly OK. return $line =~ /(First Name|Middle Name|Last Name)/; }
sub map_columns { my $line = shift;
my @names = parse_line(',', 0, $line);
my $ctr = 0; my %fieldmap = map { $_ => $ctr++ } @names;
return %fieldmap; }
sub build_vcard_attr_from_def { my ($def, $fields, $map) = @_;
# Valid chars for lookup (from Outlook CSV) are # A-Za-z0-9_-'/ # Valid chars for formatting of attr are # \s,| my @lookup = map { s/=0A$//; s/[^\w\s\-'\/]//; $_; } split /[\s,]*\|[\s,]*/, $def;
foreach my $el (@lookup) { unless (defined($map->{ $el })) { print STDERR "$el is undefined\n"; next; } if (defined($fields->[$map->{ $el }])) { unless ($fields->[$map->{ $el }] =~ /(^$|0\/0\/00)/) { $def =~ s/$el/$fields->[$map->{ $el }]/; } else { $def =~ s/((?<=\|)\s*)?$el(\s*?(?=\|))?(=0A)?,?//; } } else { $def =~ s/((?<=\|)\s*)?$el(\s*?(?=\|))?(=0A)?,?//; } } # Get rid of field delimiters $def =~ s/\|//g; # Snip off any trailing semicolons or whitespace $def =~ s/[\s;]*$//;
return $def; }
sub build_vcard_from_line { my ($line, %map) = @_; my %vcard;
my @fields = parse_line(',', 0, $line);
my %vcard_def = ( FN => 'Title |First Name |Middle Name |Last Name |Suffix', N => 'Last Name| Suffix|;First Name|;Middle Name|;Title', 'ADR;WORK' => 'PO Box|;Business Street 2|;Business Street|;Business City|;Business State|;Business Postal Code|;Business Country', 'LABEL;QUOTED-PRINTABLE;WORK' => 'PO Box |Business Street=0A|Business Street 2=0A|Business City,| Business State| Business Postal Code=0A|Business Country', 'TEL;WORK;VOICE' => 'Business Phone', 'TEL;WORK;VOICE2' => 'Business Phone 2', 'TEL;WORK;FAX' => 'Business Fax', 'TEL;WORK;COMPANY' => 'Company Main Phone', 'ADR;HOME' => ';Home Street 2|;Home Street|;Home City|;Home State|;Home Postal Code|;Home Country', 'LABEL;QUOTED-PRINTABLE;HOME' => 'Home Street=0A|Home Street 2=0A|Home City,| Home State| Home Postal Code=0A|Home Country', 'TEL;HOME;VOICE' => 'Home Phone', 'TEL;HOME;VOICE2' => 'Home Phone 2', 'TEL;HOME;FAX' => 'Home Fax', 'ADR;POSTAL' => ';Other Street 2|;Other Street|;Other City|;Other State|;Other Postal Code|;Other Country', 'LABEL;QUOTED-PRINTABLE;POSTAL' => 'Other Street=0A|Other Street 2=0A|Other City,| Other State| Other Postal Code=0A|Other Country', 'TEL;VOICE' => 'Other Phone', 'TEL;FAX' => 'Other Fax', 'TEL;CELL' => 'Mobile Phone', 'TEL;CAR' => 'Car Phone', 'TEL;PAGER' => 'Pager', 'TEL;PREF' => 'Primary Phone', 'TEL;ISDN' => 'ISDN', 'TEL;X-EVOLUTION-CALLBACK' => 'Callback', 'TEL;X-EVOLUTION-TTYTDD' => 'TTY/TDD Phone', 'TEL;X-EVOLUTION-TELEX' => 'Telex', 'TEL;X-EVOLUTION-RADIO' => 'Radio Phone', 'EMAIL;INTERNET' => 'E-mail Address', 'EMAIL;INTERNET2' => 'E-mail 2 Address', 'EMAIL;INTERNET3' => 'E-mail 3 Address', ORG => 'Company|;Department', TITLE => 'Job Title', ROLE => 'Profession', 'X-EVOLUTION-ASSISTANT' => "Assistant's Name", 'TEL;X-EVOLUTION-ASSISTANT' => "Assistant's Phone", 'X-EVOLUTION-SPOUSE' => 'Spouse', 'X-EVOLUTION-ANNIVERSARY' => 'Anniversary', 'X-EVOLUTION-MANAGER' => "Manager's Name", 'X-EVOLUTION-OFFICE' => 'Office Location', BDAY => 'Birthday', NOTE => 'Notes', FBURL => 'Internet Free Busy', URL => 'Web Page', );
foreach my $key (keys(%vcard_def)) { my $attr = build_vcard_attr_from_def($vcard_def{ $key }, \@fields, \%map); if (defined($attr)) { $vcard{ $key } = $attr unless ($attr =~ /^$/); } }
return %vcard; }
sub print_vcard_to_fh { my ($fh, %vcard) = @_;
print $fh "BEGIN:VCARD\n"; foreach my $key (keys(%vcard)) { # Dirty hack because Evolution's vcard stores multiple email addrs # with same sttribute, hence key collision. Bleah. # Ugh! Same deal for multiple phones... (eg. bus. phone) # # And finally, while we're special-casing... Outlook exports dates # differently, so munge 'em if we find 'em. if ($key =~ /EMAIL;INTERNET/o) { (my $temp = $key) =~ s/\d$//; print $fh "$temp:$vcard{ $key }\n"; } elsif ($key =~ /TEL;(HOME|WORK)/o) { (my $temp = $key) =~ s/\d$//; print $fh "$temp:$vcard{ $key }\n"; } elsif ($key =~ /(BDAY|X\-EVOLUTION\-ANNIVERSARY)/o) { my $temp = $vcard{ $key }; if ($temp =~ /(\d\d)\/(\d\d)\/(\d\d)/) { # Y2k !! MS Didn't learn anything. # Hope no one was born before 1915 if ((1900 + $3) < 1915) { print $fh "$key:20$3-$1-$2\n"; } else { print $fh "$key:19$3-$1-$2\n"; } } else { # Something's funky... Just delete the attribute print STDERR "Couldn't figure out what to do with $key:$vcard{ $key }\n"; delete($vcard{ $key }); } } else { print $fh "$key:$vcard{ $key }\n"; } } print $fh "END:VCARD\n\n"; }
my $in = $ARGV[0]; my $out = $ARGV[1];
usage() unless(defined($in) && defined($out));
open (IN, $in) or die "Can't open($in): $!\n";
open (OUT, ">$out") or die "Can't open($out): $!\n";
my $linectr = 0; my %map;
while (my $line = <IN>) { $line =~ s/\r//g; $line =~ s/\n$//; if ($linectr == 0) { $linectr++; usage() unless is_recognized_format($line); %map = map_columns($line); } else { $linectr++; # Thanks Chris! My eyes are bleeding and my head hurts, but it works! while ($line =~ /^(("([^"]|\n|"")*")?,)*"([^"]|\n|"")*$/) { my $temp = $line; $line = <IN>; $line =~ s/\r//g; $line =~ s/\n$//; $line = "$temp $line"; } my %vcard = build_vcard_from_line($line, %map); print_vcard_to_fh(\*OUT, %vcard); } }
#print STDERR "Processed ", $linectr - 1, " lines\n";
close(IN); close(OUT);
----
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com
BTW when I exported my contacts from outlook to the csv file, I lost all the contacts in outlook and the only data transfered was the category headers. :-( Tom On Thu, 2002-05-23 at 22:03, Dave Barton wrote:
On Thu, 2002-05-23 at 08:40, Tom Nielsen wrote:
Has anyone imported Outlook folders and mail into Evolution? I'm using Outlook 2k and Evolution 1.0.2.
Thanks, Tom
Tom Nielsen Neuro Logic Systems 805.389.5435 x18 www.neuro-logic.com
Hi Tom,
When I switched to Linux I successfully converted my .pst files to mbox format, together with my Outlook contacts and imported them into Evolution. It's a fairly convoluted process, but it worked for me.
If you have a strong stomach (or masochistic tendencies), make yourself a large pot of coffee (or something stronger) and give this a try:
***********************************************************************
Mozilla under Windows can access the .pst Outlook files because it can use the Windows MAPI.DLL library. Using MAPI.DLL is the only way to access .pst files, and it can be used under a Windows operating system.
To start importing your Outlook mail to Evolution, run Mozilla Mail on Windows and select the Importer to begin:
File > Import
Then select the .pst file that you wish to import Mail from Outlook. Once Mozilla has imported all your mail, reboot your computer into Linux.
Mount your Windows partition in Linux and run Evolution to begin importing your mail. Select the Importer from the File menu to start importing:
File > Import File...
Set the file type to "MBox (mbox)" and click on [Browse] to select the file containing mail you want to import.
If you are the only user on Windows, the mail files will be stored in /mnt/windows/c/Windows/Application Data/Mozilla/Profiles/default/XXXX/Mail/imported.mail/ where /mnt/windows/c/ is your windows partition mount point and XXXX is some collection of numbers and digits ending in .slt.
If there is more than one user, the file will be in /mnt/windows/c/windows/Profiles/USERNAME/XXXX/ Mail/imported.mail/ where USERNAME is your Windows username.
For each mail folder in Outlook, Mozilla will convert the folder into one mbox file. To import all your mail, import all the files into Evolution, that do not a .msf extension.
ALTERNATIVELY
You may want to get the conversion program libpst-0.3beta1.tgz which can be downloaded from http://sourceforge.net/projects/ol2mbox/
**************************************************************************
To import your contacts from Outlook you will need to export all of your contact folders in Outlook to a .csv file. To do this in Outlook:
Click on File > Import and Export.... Choose "Export to a file" and click [Next]. For the file type choose "Comma Separated Values (DOS)". Click [Next]. If you have sub-folders under "Contacts" each sub-folder must be exported separately. Name the exported files "same_as_outlook_folder.csv" (sans quotes and keep a note of the path). Click [Next]. Click [Finish].
To import contacts.csv into Evolution you will have to run each .csv file through the attached Perl script (csv2vcard.pl). Download csv2vcard.pl into your home directory and make the script executable by running this command:
$ chmod +x ~/csv2vcard.pl
Run this script to convert contacts.csv to contacts.vcf:
$ ./csv2vcard.pl contacts.csv contacts.vcf
Once you have contacts.vcf, you can import it into Evolution by:
Clicking File > Import. Click [Next]. Click on "Import from a single file" Click [Next] again. For file type choose "VCard...". Click [Browse] and select your file. Click [Next] then [Import].
**************************************************************************
Hope this helps and good luck.
Dave
----
#!/usr/bin/perl -w # # csv2vcard.pl # # Copyright (C) 2001 Ximian, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this program; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # Authors # Michael MacDonald
# Chris Lahey # # ChangeLog: # # 2001-12-12 Michael MacDonald # Hello World! # use strict; use diagnostics; use Text::ParseWords; sub usage { print STDERR << "--EndOfUsage";
Takes a CSV-formatted list of contacts from Outlook and attempts to convert it into a list of VCards suitable for import into Evolution.
Usage: $0 [infile outfile]
--EndOfUsage
exit; }
sub is_recognized_format { my $line = shift;
# Making some assumptions here... Prolly OK. return $line =~ /(First Name|Middle Name|Last Name)/; }
sub map_columns { my $line = shift;
my @names = parse_line(',', 0, $line);
my $ctr = 0; my %fieldmap = map { $_ => $ctr++ } @names;
return %fieldmap; }
sub build_vcard_attr_from_def { my ($def, $fields, $map) = @_;
# Valid chars for lookup (from Outlook CSV) are # A-Za-z0-9_-'/ # Valid chars for formatting of attr are # \s,| my @lookup = map { s/=0A$//; s/[^\w\s\-'\/]//; $_; } split /[\s,]*\|[\s,]*/, $def;
foreach my $el (@lookup) { unless (defined($map->{ $el })) { print STDERR "$el is undefined\n"; next; } if (defined($fields->[$map->{ $el }])) { unless ($fields->[$map->{ $el }] =~ /(^$|0\/0\/00)/) { $def =~ s/$el/$fields->[$map->{ $el }]/; } else { $def =~ s/((?<=\|)\s*)?$el(\s*?(?=\|))?(=0A)?,?//; } } else { $def =~ s/((?<=\|)\s*)?$el(\s*?(?=\|))?(=0A)?,?//; } } # Get rid of field delimiters $def =~ s/\|//g; # Snip off any trailing semicolons or whitespace $def =~ s/[\s;]*$//;
return $def; }
sub build_vcard_from_line { my ($line, %map) = @_; my %vcard;
my @fields = parse_line(',', 0, $line);
my %vcard_def = ( FN => 'Title |First Name |Middle Name |Last Name |Suffix', N => 'Last Name| Suffix|;First Name|;Middle Name|;Title', 'ADR;WORK' => 'PO Box|;Business Street 2|;Business Street|;Business City|;Business State|;Business Postal Code|;Business Country', 'LABEL;QUOTED-PRINTABLE;WORK' => 'PO Box |Business Street=0A|Business Street 2=0A|Business City,| Business State| Business Postal Code=0A|Business Country', 'TEL;WORK;VOICE' => 'Business Phone', 'TEL;WORK;VOICE2' => 'Business Phone 2', 'TEL;WORK;FAX' => 'Business Fax', 'TEL;WORK;COMPANY' => 'Company Main Phone', 'ADR;HOME' => ';Home Street 2|;Home Street|;Home City|;Home State|;Home Postal Code|;Home Country', 'LABEL;QUOTED-PRINTABLE;HOME' => 'Home Street=0A|Home Street 2=0A|Home City,| Home State| Home Postal Code=0A|Home Country', 'TEL;HOME;VOICE' => 'Home Phone', 'TEL;HOME;VOICE2' => 'Home Phone 2', 'TEL;HOME;FAX' => 'Home Fax', 'ADR;POSTAL' => ';Other Street 2|;Other Street|;Other City|;Other State|;Other Postal Code|;Other Country', 'LABEL;QUOTED-PRINTABLE;POSTAL' => 'Other Street=0A|Other Street 2=0A|Other City,| Other State| Other Postal Code=0A|Other Country', 'TEL;VOICE' => 'Other Phone', 'TEL;FAX' => 'Other Fax', 'TEL;CELL' => 'Mobile Phone', 'TEL;CAR' => 'Car Phone', 'TEL;PAGER' => 'Pager', 'TEL;PREF' => 'Primary Phone', 'TEL;ISDN' => 'ISDN', 'TEL;X-EVOLUTION-CALLBACK' => 'Callback', 'TEL;X-EVOLUTION-TTYTDD' => 'TTY/TDD Phone', 'TEL;X-EVOLUTION-TELEX' => 'Telex', 'TEL;X-EVOLUTION-RADIO' => 'Radio Phone', 'EMAIL;INTERNET' => 'E-mail Address', 'EMAIL;INTERNET2' => 'E-mail 2 Address', 'EMAIL;INTERNET3' => 'E-mail 3 Address', ORG => 'Company|;Department', TITLE => 'Job Title', ROLE => 'Profession', 'X-EVOLUTION-ASSISTANT' => "Assistant's Name", 'TEL;X-EVOLUTION-ASSISTANT' => "Assistant's Phone", 'X-EVOLUTION-SPOUSE' => 'Spouse', 'X-EVOLUTION-ANNIVERSARY' => 'Anniversary', 'X-EVOLUTION-MANAGER' => "Manager's Name", 'X-EVOLUTION-OFFICE' => 'Office Location', BDAY => 'Birthday', NOTE => 'Notes', FBURL => 'Internet Free Busy', URL => 'Web Page', );
foreach my $key (keys(%vcard_def)) { my $attr = build_vcard_attr_from_def($vcard_def{ $key }, \@fields, \%map); if (defined($attr)) { $vcard{ $key } = $attr unless ($attr =~ /^$/); } }
return %vcard; }
sub print_vcard_to_fh { my ($fh, %vcard) = @_;
print $fh "BEGIN:VCARD\n"; foreach my $key (keys(%vcard)) { # Dirty hack because Evolution's vcard stores multiple email addrs # with same sttribute, hence key collision. Bleah. # Ugh! Same deal for multiple phones... (eg. bus. phone) # # And finally, while we're special-casing... Outlook exports dates # differently, so munge 'em if we find 'em. if ($key =~ /EMAIL;INTERNET/o) { (my $temp = $key) =~ s/\d$//; print $fh "$temp:$vcard{ $key }\n"; } elsif ($key =~ /TEL;(HOME|WORK)/o) { (my $temp = $key) =~ s/\d$//; print $fh "$temp:$vcard{ $key }\n"; } elsif ($key =~ /(BDAY|X\-EVOLUTION\-ANNIVERSARY)/o) { my $temp = $vcard{ $key }; if ($temp =~ /(\d\d)\/(\d\d)\/(\d\d)/) { # Y2k !! MS Didn't learn anything. # Hope no one was born before 1915 if ((1900 + $3) < 1915) { print $fh "$key:20$3-$1-$2\n"; } else { print $fh "$key:19$3-$1-$2\n"; } } else { # Something's funky... Just delete the attribute print STDERR "Couldn't figure out what to do with $key:$vcard{ $key }\n"; delete($vcard{ $key }); } } else { print $fh "$key:$vcard{ $key }\n"; } } print $fh "END:VCARD\n\n"; }
my $in = $ARGV[0]; my $out = $ARGV[1];
usage() unless(defined($in) && defined($out));
open (IN, $in) or die "Can't open($in): $!\n";
open (OUT, ">$out") or die "Can't open($out): $!\n";
my $linectr = 0; my %map;
while (my $line = <IN>) { $line =~ s/\r//g; $line =~ s/\n$//; if ($linectr == 0) { $linectr++; usage() unless is_recognized_format($line); %map = map_columns($line); } else { $linectr++; # Thanks Chris! My eyes are bleeding and my head hurts, but it works! while ($line =~ /^(("([^"]|\n|"")*")?,)*"([^"]|\n|"")*$/) { my $temp = $line; $line = <IN>; $line =~ s/\r//g; $line =~ s/\n$//; $line = "$temp $line"; } my %vcard = build_vcard_from_line($line, %map); print_vcard_to_fh(\*OUT, %vcard); } }
#print STDERR "Processed ", $linectr - 1, " lines\n";
close(IN); close(OUT);
----
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com
participants (3)
-
Dave Barton
-
James Ogley
-
Tom Nielsen