[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>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2><SPAN class=022483120-10102003>#Ben 
Hall<BR>#www.benhall.co.uk</SPAN></FONT></DIV>
<DIV>&nbsp;</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>&nbsp;</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 &amp; MAPI...\n";</DIV>
<DIV>&nbsp;</DIV>
<DIV>Win32::OLE-&gt;Initialize(Win32::OLE::COINIT_OLEINITIALIZE); # needs this 
magic incantation<BR>my $session = 
Win32::OLE-&gt;new("MAPI.Session");<BR>if(Win32::OLE-&gt;LastError() != 0) 
{<BR>&nbsp;die "Could not create a new MAPI Session: ", 
Win32::OLE-&gt;LastError(), "\n";<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>#<BR># Attempt to log on<BR>#<BR>print "Logging on to Exchange 
server...\n";</DIV>
<DIV>&nbsp;</DIV>
<DIV>my $err = $session-&gt;Logon($sender, $passwd);<BR>if ($err) {<BR>&nbsp;die 
"Logon failed: $!";<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>my $store = $session-&gt;InfoStores("Mailbox - Ken Cornetet");<BR>my 
$folder = $store-&gt;RootFolder-&gt;Folders("Inbox");</DIV>
<DIV>&nbsp;</DIV>
<DIV>print "Checking for messages...\n";</DIV>
<DIV>&nbsp;</DIV>
<DIV>my $messages = $folder-&gt;Messages;<BR>my $message_count = 
$messages-&gt;Count;<BR>my $msg = "";</DIV>
<DIV>&nbsp;</DIV>
<DIV>print "\nNumber of messages: ".$message_count."\n";</DIV>
<DIV>&nbsp;</DIV>
<DIV>for( my $i=1 ; $i&lt;=$message_count ; $i++) {<BR>&nbsp;if ($i == 1) 
{<BR>&nbsp;&nbsp;$msg = $messages-&gt;GetFirst();<BR>&nbsp;} else 
{<BR>&nbsp;&nbsp;$msg = $messages-&gt;GetNext();<BR>&nbsp;}<BR>&nbsp;print 
"From: ", $msg-&gt;{Sender}-&gt;{Address}, "\n";<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>$session-&gt;Logoff();</DIV>
<DIV>&nbsp;</DIV>
<DIV># end of script</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2></FONT>&nbsp;</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.&nbsp; </SPAN></FONT></DIV>
  <DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
  class=703000719-09102003></SPAN></FONT>&nbsp;</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.&nbsp; 
  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.&nbsp; I want to avoid</FONT> 
  <BR><FONT size=2>opening any windows at all, because this is for an unattended 
  application form processor.&nbsp; Anyone have any ideas?</FONT> </P><BR>
  <P><FONT size=2>&nbsp; -- </FONT></P>
  <P><FONT size=2>Ed Ahlsen-Girard&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A 
  href="mailto:edward.ahlsen-girard@eglin.af.mil">mailto:edward.ahlsen-girard@eglin.af.mil</A> 
  &lt;<A 
  href="mailto:edward.ahlsen-girard@eglin.af.mil">mailto:edward.ahlsen-girard@eglin.af.mil</A>&gt;&nbsp; 
  </FONT><BR><FONT size=2>Network Administrator&nbsp;&nbsp; 
  850-882-6540x5349&nbsp;&nbsp; ESC/ACU OL1 </FONT><BR><FONT size=2>TYBRIN 
  Corporation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DSN:872-6540x5349&nbsp;&nbsp; 205 
  West D Ave (Bldg 350), Ste 628</FONT> <BR><FONT size=2>LAN 
  Integration&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FAX: 
  850-882-6379&nbsp;&nbsp; Eglin AFB, FL 32542</FONT> </P>
  <P><FONT size=2><A href="http://www.tybrin.com" 
  target=_blank>http://www.tybrin.com</A> &lt;<A href="http://www.tybrin.com" 
  target=_blank>http://www.tybrin.com</A>&gt;&nbsp; <A 
  href="http://www.eglin.af.mil/mission-planning" 
  target=_blank>http://www.eglin.af.mil/mission-planning</A></FONT> <BR><FONT 
  size=2>&lt;<A href="http://www.eglin.af.mil/mission-planning" 
  target=_blank>http://www.eglin.af.mil/mission-planning</A>&gt;&nbsp; 
  </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