Hi,
Using perl I wanted to read email from my outlook as soon as new email arrives then planning to implement next logic depending on the subject....
I am using Microsoft outlook 2010
I found following program from cpan but upon execution I get the following error...
-------------
C:\Automation\OutlookPERL>perl reademail.pl
Can't locate Win64/OLE/Const.pm in @INC (@INC contains: ./lib C:/Perl64/site/lib
C:/Perl64/lib .) at reademail.pl line 10.
BEGIN failed--compilation aborted at reademail.pl line 10.
-------------------
line 10 is as below------------
use Win64::OLE::Const 'Microsoft Outlook';
-----------------------------------------
I tried to get related modules from PPM but failed, I am not expert but I can say I am intermediate programmer
Please suggest how to run the following program
Thanks in advance
complete program from cpan.org
-----------------------------
# create the object
use Mail::Outlook;
my $outlook = new Mail::Outlook();
# start with a folder
my $outlook = new Mail::Outlook('Inbox');
# use the Win32::OLE::Const definitions
use Mail::Outlook;
use Win64::OLE::Const 'Microsoft Outlook';
my $outlook = new Mail::Outlook(olInbox);
# get/set the current folder
my $folder = $outlook->folder();
my $folder = $outlook->folder('Inbox');
# get the first/last/next/previous message
my $message = $folder->first();
$message = $folder->next();
$message = $folder->last();
$message = $folder->previous();
# read the attributes of the current message
my $text = $message->From();
$text = $message->To();
$text = $message->Cc();
$text = $message->Bcc();
$text = $message->Subject();
$text = $message->Body();
my @list = $message->Attach();
# use Outlook to display the current message
$message->display;
# create a message for sending
my $message = $outlook->create();
$message->To('you@example.com');
$message->Cc('Them <them@example.com>');
$message->Bcc('Us <us@example.com>; anybody@example.com');
$message->Subject('Blah Blah Blah');
$message->Body('Yadda Yadda Yadda');
$message->Attach(@lots_of_files);
$message->Attach(@more_files); # attachments are appended
$message->Attach($one_file); # so multiple calls are allowed
$message->send;
# Or use a hash
my %hash = (
To => 'you@example.com',
Cc => 'Them <them@example.com>',
Bcc => 'Us <us@example.com>, anybody@example.com',
Subject => 'Blah Blah Blah',
Body => 'Yadda Yadda Yadda',
);
my $message = $outlook->create(%hash);
$message->display(%hash);
$message->send(%hash);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.