Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#########################################################################################

#- -- This program inspects the internet header of all Microsoft Outlook (2002 SP-2)  messages in the user-defined “MyAccount”

#--  directory to determine if the email was sent to myaccount@charter.net   If this is not the case, then it is spam and

#--  the program puts the email in the “Deleted Items” folder.  If the email was sent to myaccount@charter.net place

#-- 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@charter.net

####################################################################################################

 

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 folder

  $Root                        = $Inbox->Parent();

  $MyAccount            = $Root->Folders("MyAccount");

  $MyAccountOK      = $MyAccount->Folders("Filtered");

  $Clip                          = Win32::Clipboard();

 

  @wins = Win32::GuiTest::FindWindowLike(0,"^Microsoft Outlook",'mspim_wnd32');       #-- mspim_wnd32 is the class

  Win32::GuiTest::SetForegroundWindow($wins[0]);

 

  $cnt=$MyAccount->Items->Count;     #-- get a count of messages in folder "MyAccount"

 

   while ($cnt > 0) {

 

        $Clip->Empty();       #-- empty the clipboard

 

        $MyAccount->Items($cnt)->Display;       #-- display/open message with index of $cnt in the MyAccount folder

       

        Win32::GuiTest::SendKeys("%Vp");                                                #-- open options dialog  ALT-V-p

        Win32::GuiTest::SendKeys("{TAB 6}");                                          #-- move down to internet header field

        Win32::GuiTest::SendKeys("{APP} {DOWN 2} {ENTER}");       #-- put internet header in clipboard

        Win32::GuiTest::SendKeys("{TAB}");                                             #-- move to Cancel Button

        Win32::GuiTest::SendKeys("{ENTER}");                                        #-- press Cancel Button

        Win32::GuiTest::SendKeys("%{F4}");                                           #-- close message   ALT-F4

 

        undef $text;

        $text=$Clip->Get();             #-- get clipboard contents

        $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 header text

        if ($text !~ /myaccount\@charter\.net/) {

           $MyAccount->Items($cnt)->Move($Deleted);                 #-- move message to “Deleted Items” folder      

        } else {

           $MyAccount->Items($cnt)->Move($MyAccountOK);    #-- move message to “MyAccount->Filtered folder

        }

 

        $cnt--;

  }

 

 #--  end script

  

 


In reply to Re: Win32::OLE Outlook and E-mail security update by Anonymous Monk
in thread Win32::OLE Outlook and E-mail security update by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (9)
    As of 2015-07-06 08:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (70 votes), past polls