For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > May 2006 > How to handle(read & write) emails using perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to handle(read & write) emails using perl
Poonam Pahil

2006-05-24, 3:59 am

Hi,

Is it possible to open an outlook mail message using perl. If yes, can
somebody please suggest what should I read to make this happen(Is it CGI).
I want to read from a mail message (iam using outlook currently).Also format
a mail - creating a table in a mail message & then inserting data into it.
Also update the To, CC & Subject fields.

Any suggestions would be appreciated.

Thanks,
Poonam

Anish Kumar K.

2006-05-24, 3:59 am

Please check out this

http://search.cpan.org/src/BARBIE/M...Mail/Outlook.pm

Anish

Poonam Pahil wrote:
> Hi,
>
> Is it possible to open an outlook mail message using perl. If yes, can
> somebody please suggest what should I read to make this happen(Is it
> CGI).
> I want to read from a mail message (iam using outlook currently).Also
> format
> a mail - creating a table in a mail message & then inserting data into
> it.
> Also update the To, CC & Subject fields.
>
> Any suggestions would be appreciated.
>
> Thanks,
> Poonam
>


niall.macpherson@ntlworld.com

2006-05-24, 6:58 pm


Poonam Pahil wrote:

> Hi,
>
> Is it possible to open an outlook mail message using perl. If yes, can
> somebody please suggest what should I read to make this happen(Is it CGI).
> I want to read from a mail message (iam using outlook currently)


The following works for me. It should read messages from a specified
outlook folder (will need tweaking to reflect the folder you want to
read) and the message will be in $message->{Body}

---------------------------------------------------------------------------------------------------------------------------
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
use Data::Dumper;

#-------------------------------------------------------------
#
# Test outlook interface
#
#
#-------------------------------------------------------------

my $outlook = Win32::OLE->new('Outlook.Application') or die
"Error!\n";

my $namespace = $outlook->GetNamespace("MAPI");

## Change this to reflect your folder structure
my $folder = $namespace->Folders('Personal Folders')
->Folders('Archive Mail')
->Folders('TestPerlOutlook');

my $items = $folder->Items;

for my $itemIndex (1..$items->Count)
{
my $message = $items->item($itemIndex);

next if not defined $message;

print Dumper 'Subject ' . $message->{Subject};
print Dumper 'Date ' . $message->{Date};
print Dumper 'Sender ' . $message->{SenderName};
print Dumper 'To ' . $message->{To};
print Dumper 'Body ' . $message->{Body};
}

exit(0);
----------------------------------------------------------------------------------------------------------------------

I haven't yet tried writing email messages so I can't help you with
that part

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com