Loading ...
Sorry, an error occurred while loading the content.
 

Re: How to programmatically inspect internet header of Outlook 2002 emails

Expand Messages
  • Eric
    As an alternative to the original code example, if you wish to not rely of Microsoft Outlook already running, you can create a new com object with this line of
    Message 1 of 2 , Jun 8 8:52 AM
      As an alternative to the original code example, if you wish to not
      rely of Microsoft Outlook already running, you can create a new com
      object with this line of code:

      $OL = Win32::OLE->new('Outlook.Application');

      Doing so allows you to comment out the below lines of code
      from the original code example:

      # $OL = Win32::OLE->GetActiveObject('Outlook.Application');
      # @wins = Win32::GuiTest::FindWindowLike(0,"^Microsoft
      # Outlook",'mspim_wnd32');
      # Win32::GuiTest::SetForegroundWindow($wins[0]);




      --- In perlguitest@yahoogroups.com, "Eric" <eric_hansen85@y...> wrote:
      > #-- This program inspects the internet header of all Microsoft
      > #-- Outlook (2002, SP-2) messages in the user-defined
      > #-- "MyAccount" directory to determine if our email account
      > #-- myaccount@c... is listed.
      > #--
      > #-- If this is not the case, then the email is considered spam
      > #-- to us, and the program puts the email in the
      > #-- "Deleted Items" folder. If the internet header contains
      > #-- myaccount@c..., then program places the email in the
      > #-- MyAccount->Filtered folder. This program assumes Microsoft
      > #-- Outlook is running. This program does not cause the Outlook
      > #-- Security Window to open, so nothing to worry about.
      > #--
      > #-- Author – Eric C. Hansen, May 2004 eric.amerwood@c...
      >
      > 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 items
      > $Root = $Inbox->Parent();
      > $MyAccount = $Root->Folders("MyAccount");
      > $MyAccountOK = $MyAccount->Folders("Filtered");
      >
      > $Clip = Win32::Clipboard();
      >
      > @wins = Win32::GuiTest::FindWindowLike(0,"^Microsoft
      > Outlook",'mspim_wnd32');
      >
      > Win32::GuiTest::SetForegroundWindow($wins[0]);
      >
      > $cnt=$MyAccount->Items->Count;
      >
      > while ($cnt > 0) {
      >
      > $Clip->Empty(); #-- empty the clipboard
      >
      > $MyAccount->Items($cnt)->Display #-- display message
      >
      > #-- use this key sequence to copy internet header to clipboard.
      > Win32::GuiTest::SendKeys("%Vp");
      > Win32::GuiTest::SendKeys("{TAB 6}");
      > Win32::GuiTest::SendKeys("{APP} {DOWN 2} {ENTER}");
      > Win32::GuiTest::SendKeys("{TAB}");
      > Win32::GuiTest::SendKeys("{ENTER}");
      > Win32::GuiTest::SendKeys("%{F4}");
      >
      > undef $text;
      > $text=$Clip->Get(); #-- get clipboard contents
      > $text=lc($text); #-- convert to lowercase
      >
      > #-- now check for our email address in the
      > #-- internet header text.
      >
      > if ($text !~ /myaccount\@charter\.net/) {
      > $MyAccount->Items($cnt)->Move($Deleted);
      > } else {
      > $MyAccount->Items($cnt)->Move($MyAccountOK);
      > }
      >
      > $cnt--;
      > }
      >
      > #-- end script
    Your message has been successfully submitted and would be delivered to recipients shortly.