Greating wise ones.
I have a script that creates a MAPI session to a microsoft exchange server to scrape through emails. The code works great unless the Exchange server is not available. When this happens I get a popup which reads "Your microsoft exchange server is unavailable" and the script hangs until I click OK on the popup. I was hoping that someone else had run into this before and could tell me how to disable the popup so I can just capture the error and send myself an alert. The connection code is listed below.
Any help as always is greatly appreciated.
my ($server, $alias, $rconn) = @_; # connect to mailbox of CN $
+alias using server $server
my $mapikey = "$server\n$alias";
my $err;
my $session = Win32::OLE->new(qw(Win32::OLE->new(qw(MAPI.Session))
+)) or die Win32::OLE->LastError();
# Try to logon with dynamic profile under current account.
# This may need a reasonable current CDO on your machine.
my $mapi = $session->Logon(undef,undef,undef,1,undef,undef,$mapike
+y);
return $err if $err = Win32::OLE->LastError();
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.