[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-web
Subject: RE: reading mail from Exchange
From: "Ken Cornetet" <Ken.Cornetet () kimball ! com>
Date: 2003-10-10 20:32:57
[Download RAW message or body]
Here's a snippet that will get you started:
#Ben Hall
#www.benhall.co.uk
use strict;
use Win32::OLE qw(in with OVERLOAD);
# outlook profile
my $sender = "Ken Cornetet 1";
my $passwd = ""; # your password here
#
# PROGRAM STARTS HERE
#
# Create a new MAPI Session
#
print "Initialising OLE & MAPI...\n";
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); # needs this
magic incantation
my $session = Win32::OLE->new("MAPI.Session");
if(Win32::OLE->LastError() != 0) {
die "Could not create a new MAPI Session: ", Win32::OLE->LastError(),
"\n";
}
#
# Attempt to log on
#
print "Logging on to Exchange server...\n";
my $err = $session->Logon($sender, $passwd);
if ($err) {
die "Logon failed: $!";
}
my $store = $session->InfoStores("Mailbox - Ken Cornetet");
my $folder = $store->RootFolder->Folders("Inbox");
print "Checking for messages...\n";
my $messages = $folder->Messages;
my $message_count = $messages->Count;
my $msg = "";
print "\nNumber of messages: ".$message_count."\n";
for( my $i=1 ; $i<=$message_count ; $i++) {
if ($i == 1) {
$msg = $messages->GetFirst();
} else {
$msg = $messages->GetNext();
}
print "From: ", $msg->{Sender}->{Address}, "\n";
}
$session->Logoff();
# end of script
-----Original Message-----
From: Raymond Forbes [mailto:rforbes@e-stalkers.net]
Sent: Thursday, October 09, 2003 2:08 PM
To: 'Ahlsen-Girard Edward F Contr ESC/ACU OL1'; 'Prohaska, Tim';
perl-win32-web@listserv.ActiveState.com
Subject: RE: reading mail from Exchange
I would like a similar solution if one is possible.
I am making a "heartbeat" check you could say. I want an
account to log in and check mail and i can use that to determine the
status of the exchange server.
_____
From: perl-win32-web-admin@listserv.ActiveState.com
[mailto:perl-win32-web-admin@listserv.ActiveState.com] On Behalf Of
Ahlsen-Girard Edward F Contr ESC/ACU OL1
Sent: Thursday, October 09, 2003 11:56 AM
To: 'Prohaska, Tim'; Ahlsen-Girard Edward F Contr ESC/ACU OL1;
perl-win32-web@listserv.ActiveState.com
Subject: RE: reading mail from Exchange
Not an option - I don't control the server.
-----Original Message-----
From: Prohaska, Tim [mailto:tim.prohaska@honeywell.com]
Sent: Thursday, October 09, 2003 13:35
To: 'Ahlsen-Girard Edward F Contr ESC/ACU OL1';
perl-win32-web@listserv.ActiveState.com
Subject: RE: reading mail from Exchange
Have you considered using an IMAP client.
-----Original Message-----
From: Ahlsen-Girard Edward F Contr ESC/ACU OL1
[mailto:edward.ahlsen-girard@eglin.af.mil]
Sent: Thursday, October 09, 2003 12:52 PM
To: perl-win32-web@listserv.ActiveState.com
Subject: reading mail from Exchange
I am trying to get a script to read mail from an Exchange server
that does *not* allow POP3 clients. I want to avoid
opening any windows at all, because this is for an unattended
application form processor. Anyone have any ideas?
--
Ed Ahlsen-Girard mailto:edward.ahlsen-girard@eglin.af.mil
<mailto:edward.ahlsen-girard@eglin.af.mil>
Network Administrator 850-882-6540x5349 ESC/ACU OL1
TYBRIN Corporation DSN:872-6540x5349 205 West D Ave (Bldg
350), Ste 628
LAN Integration FAX: 850-882-6379 Eglin AFB, FL 32542
http://www.tybrin.com <http://www.tybrin.com>
http://www.eglin.af.mil/mission-planning
<http://www.eglin.af.mil/mission-planning>
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY><FONT color=#0000ff size=2></FONT>
<DIV></DIV>
<DIV><FONT color=#0000ff size=2><SPAN class=022483120-10102003>Here's a snippet
that will get you started:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff size=2><SPAN
class=022483120-10102003></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff size=2><SPAN class=022483120-10102003>#Ben
Hall<BR>#www.benhall.co.uk</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2><SPAN class=022483120-10102003>use
strict;<BR>use Win32::OLE qw(in with OVERLOAD);</SPAN></FONT></DIV>
<DIV> </DIV><FONT color=#0000ff size=2><SPAN class=022483120-10102003>
<DIV><BR># outlook profile<BR>my $sender = "Ken Cornetet 1";<BR>my $passwd = "";
# your password here<BR>#<BR># PROGRAM STARTS HERE<BR>#<BR># Create a new MAPI
Session<BR>#<BR>print "Initialising OLE & MAPI...\n";</DIV>
<DIV> </DIV>
<DIV>Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); # needs this
magic incantation<BR>my $session =
Win32::OLE->new("MAPI.Session");<BR>if(Win32::OLE->LastError() != 0)
{<BR> die "Could not create a new MAPI Session: ",
Win32::OLE->LastError(), "\n";<BR>}</DIV>
<DIV> </DIV>
<DIV>#<BR># Attempt to log on<BR>#<BR>print "Logging on to Exchange
server...\n";</DIV>
<DIV> </DIV>
<DIV>my $err = $session->Logon($sender, $passwd);<BR>if ($err) {<BR> die
"Logon failed: $!";<BR>}</DIV>
<DIV> </DIV>
<DIV>my $store = $session->InfoStores("Mailbox - Ken Cornetet");<BR>my
$folder = $store->RootFolder->Folders("Inbox");</DIV>
<DIV> </DIV>
<DIV>print "Checking for messages...\n";</DIV>
<DIV> </DIV>
<DIV>my $messages = $folder->Messages;<BR>my $message_count =
$messages->Count;<BR>my $msg = "";</DIV>
<DIV> </DIV>
<DIV>print "\nNumber of messages: ".$message_count."\n";</DIV>
<DIV> </DIV>
<DIV>for( my $i=1 ; $i<=$message_count ; $i++) {<BR> if ($i == 1)
{<BR> $msg = $messages->GetFirst();<BR> } else
{<BR> $msg = $messages->GetNext();<BR> }<BR> print
"From: ", $msg->{Sender}->{Address}, "\n";<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>$session->Logoff();</DIV>
<DIV> </DIV>
<DIV># end of script</DIV>
<DIV> </DIV>
<DIV><BR></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Raymond
Forbes [mailto:rforbes@e-stalkers.net] <BR><B>Sent:</B> Thursday, October 09,
2003 2:08 PM<BR><B>To:</B> 'Ahlsen-Girard Edward F Contr ESC/ACU OL1';
'Prohaska, Tim'; perl-win32-web@listserv.ActiveState.com<BR><B>Subject:</B> RE:
reading mail from Exchange<BR><BR></DIV></FONT>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=703000719-09102003>I would like a similar solution if one is
possible. </SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=703000719-09102003></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=703000719-09102003>I am making a "heartbeat" check you could say.
I want an account to log in and check mail and i can use that to determine the
status of the exchange server.</SPAN></FONT></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
perl-win32-web-admin@listserv.ActiveState.com
[mailto:perl-win32-web-admin@listserv.ActiveState.com] <B>On Behalf Of
</B>Ahlsen-Girard Edward F Contr ESC/ACU OL1<BR><B>Sent:</B> Thursday, October
09, 2003 11:56 AM<BR><B>To:</B> 'Prohaska, Tim'; Ahlsen-Girard Edward F Contr
ESC/ACU OL1; perl-win32-web@listserv.ActiveState.com<BR><B>Subject:</B> RE:
reading mail from Exchange<BR></FONT><BR></DIV>
<DIV></DIV>
<P><FONT size=2>Not an option - I don't control the server.</FONT> </P>
<P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From:
Prohaska, Tim [<A
href="mailto:tim.prohaska@honeywell.com">mailto:tim.prohaska@honeywell.com</A>]</FONT>
<BR><FONT size=2>Sent: Thursday, October 09, 2003 13:35</FONT> <BR><FONT
size=2>To: 'Ahlsen-Girard Edward F Contr ESC/ACU OL1';</FONT> <BR><FONT
size=2>perl-win32-web@listserv.ActiveState.com</FONT> <BR><FONT
size=2>Subject: RE: reading mail from Exchange</FONT> </P><BR>
<P><FONT size=2>Have you considered using an IMAP client.</FONT> </P>
<P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From:
Ahlsen-Girard Edward F Contr ESC/ACU OL1 [<A
href="mailto:edward.ahlsen-girard@eglin.af.mil">mailto:edward.ahlsen-girard@eglin.af.mil</A>]</FONT>
<BR><FONT size=2>Sent: Thursday, October 09, 2003 12:52 PM</FONT> <BR><FONT
size=2>To: perl-win32-web@listserv.ActiveState.com</FONT> <BR><FONT
size=2>Subject: reading mail from Exchange</FONT> </P><BR><BR>
<P><FONT size=2>I am trying to get a script to read mail from an Exchange
server that does *not* allow POP3 clients. I want to avoid</FONT>
<BR><FONT size=2>opening any windows at all, because this is for an unattended
application form processor. Anyone have any ideas?</FONT> </P><BR>
<P><FONT size=2> -- </FONT></P>
<P><FONT size=2>Ed Ahlsen-Girard <A
href="mailto:edward.ahlsen-girard@eglin.af.mil">mailto:edward.ahlsen-girard@eglin.af.mil</A>
<<A
href="mailto:edward.ahlsen-girard@eglin.af.mil">mailto:edward.ahlsen-girard@eglin.af.mil</A>>
</FONT><BR><FONT size=2>Network Administrator
850-882-6540x5349 ESC/ACU OL1 </FONT><BR><FONT size=2>TYBRIN
Corporation DSN:872-6540x5349 205
West D Ave (Bldg 350), Ste 628</FONT> <BR><FONT size=2>LAN
Integration FAX:
850-882-6379 Eglin AFB, FL 32542</FONT> </P>
<P><FONT size=2><A href="http://www.tybrin.com"
target=_blank>http://www.tybrin.com</A> <<A href="http://www.tybrin.com"
target=_blank>http://www.tybrin.com</A>> <A
href="http://www.eglin.af.mil/mission-planning"
target=_blank>http://www.eglin.af.mil/mission-planning</A></FONT> <BR><FONT
size=2><<A href="http://www.eglin.af.mil/mission-planning"
target=_blank>http://www.eglin.af.mil/mission-planning</A>>
</FONT></P></BLOCKQUOTE></BODY></HTML>
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic