in reply to Read new mails in MS Outlook

If you have your outlook set up like most people, what you want is not going to work, at least not with that module.

When outlook retrieves the mail from the mail server, it will delete it from the server. Which means it will not be accessible there anymore if you try to get it through perl or any other client from that server. (I'm assuming here of course that your mail server is a POP server, and not IMAP or Exchange.

Since the mail is already in outlook, you should probably look at some of the modules that interact directly with it. Look in the Win32::OLE family of modules

Another possible approach, but somewhat fragile, is to set up outlook to not delete the mails from the server, and then have your script delete them after retrieval. Of course that means you run the risk of having your script delete the mails before outlook got to them

Replies are listed 'Best First'.
Re^2: Read new mails in MS Outlook
by Nalina (Monk) on Aug 17, 2004 at 06:47 UTC
    I am trying to read all mails in inbox of MS Outlook. The script is
    use Win32::OLE; #use Win32::GuiTest; use Win32::Clipboard; $OL = Win32::OLE->GetActiveObject('Outlook.Application'); $NameSpace = $OL->GetNameSpace("MAPI"); $Inbox = $NameSpace->GetDefaultFolder(6); #-- inbox folder $Deleted = $NameSpace->GetDefaultFolder(3); #-- deleted it +ems folder $Root = $Inbox->Parent(); $MyAccount = $Root->Folders("Inbox"); $MyAccountOK = $MyAccount->Folders("Filtered"); $Clip = Win32::Clipboard(); #$Clip->Empty(); $cnt=$MyAccount->Items->Count; print "count = $cnt"; while ($cnt > 0) { $Clip->Empty(); #-- empty the clipboard #$MyAccount->Items($cnt)->Display; #-- display/open me +ssage with index of $cnt in the MyAccount folder undef $text; $text=$Clip->Get(); #-- get clipboard contents #print "text = $text\n"; $text=~tr/A-Za-z.@/*/c; #-- convert all but listed valid + characters to * $text=~tr/*//d; #-- now delete asterisks $text=lc($text); #-- convert to lowercase # -- now check for our email address in the internet heade +r text if ($text !~ /myaccount\@yahoo\.com/) { print "No\t"; #-- move message to De +leted Items folder } else { print "Yes\n"; $MyAccount->Items($cnt)->Move($MyAccountOK); #-- m +ove message to MyAccount->Filtered folder } $cnt--; }
    But $text is empty. Clipboard does not has anything( $text=$Clip->Get();). Please help me.
Re^2: Read new mails in MS Outlook
by Nalina (Monk) on Aug 17, 2004 at 05:13 UTC
    Could u please tell me how to use Win32::OLE module to extract new mails.
      I'm afraid I won't be able to help you here. I've only read about the Win32::OLE modules and have never used them myself (I do all my perl programming on linux)