Add-On for Reducing EE Email Clutter using Outlook

AID: 5297
  • Status: Published

6420 points

  • ByQlemo
  • TypeTips/Tricks
  • Posted on2011-04-23 at 15:56:09
Awards
  • Experts Exchange Approved

This is an Add-On procedure to be used in conjunction with the code provided in Reducing EE Email Clutter using Outlook, because it uses the "tagging system" of that article.


Purpose

Imagine the following situation: You have read the prior article, and implemented the code provided, and your EE Email is organized in a better way now.  Maybe you even used conditional colouring to emphasize specific topics.
But you have still 500 notification mails for the last 4 days in your inbox informing you about new questions you have set a filter for, or neglected questions of areas you are a Designated Expert in.  You pick one or another of those questions, maybe posted the prior day already, to provide suggestions.  You go into the questions, and find them answered and closed already.

Well, that can't happen anymore, if you apply this code on all or some of your questions! It will go thru the (EE assigned) inbox completely (if nothing is selected), or only thru the selected posts, and look whether the question is already closed or deleted. If so, it is removed from the inbox, and you can be sure about each remaining question being worth to have a look into it.

For Page Editors: The code also checks for deleted articles, and removes the notif then. It is more difficult to extend to check for the other states, like Editor or Author Review, or (Re-)Published, since that is not reflected in the printer-friendly version.


Inside the code

Since it isn't much of code, I'll provide it "inline" here. But before you can use it, you need to put
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliSeconds As Long)
                                    
1:

Select allOpen in new window

at the very beginning of the VBA Module you add the code to (before any procedure or function declaration).
In addition you need to add a reference to IE. While in the VBA Editor, choose Extras » References, search for "Microsoft Internet Controls" and tick it. That allows us to use Early Binding of Internet Explorer, that is we can directly access its properties. For a property description, see MSDN.

Sub CheckForClosed()
Static Web As InternetExplorer
Dim pos0, pos1 As Integer
Dim str, c As String
Dim Sel
Dim ml As MailItem
Dim q#, del#, sol#
Dim isArticle As Boolean
 
  If Web Is Nothing Or TypeName(Web) <> "IWebBrowser2" Then Set Web = CreateObject("InternetExplorer.Application")
  ' Web.Visible = True
    
  Set Sel = myOlEEItems
  If Outlook.ActiveExplorer.Selection.Count > 0 Then
    If TypeName(Outlook.ActiveExplorer.Selection.item(1)) = "MailItem" Then
      Set Sel = Outlook.ActiveExplorer.Selection
    End If
  End If
  
  For Each ml In Sel
    str = ""
    On Error Resume Next
    str = ml.UserProperties("Reference")
    q# = q# + 1
    On Error GoTo 0
    If str <> "" Then
      isArticle = (Left(str, 1) = "A")
      If isArticle Then
        str = "http://e-e.com/viewArticlePrinterFriendly.jsp?articleID=" & Mid$(str, 3)
      Else
        str = "http://e-e.com/viewQuestionPrinterFriendly.jsp?qid=" & Mid$(str, 3)
      End If
      Web.Navigate (str)
      While Web.ReadyState <> READYSTATE_COMPLETE: Sleep 10: Wend
      str = LCase(Left$(Web.Document.Body.InnerHtml, 2000))
      If isArticle Then
        str = Mid$(str, InStr(str, "<div class=""postabletype"">") + Len("<div class=""postabletype"">"))
      Else
        str = Mid$(str, InStr(str, "<div class=""questiontype"">") + Len("<div class=""questiontype"">"))
      End If
      str = Left$(str, InStr(str, "</div>") - 1)
      str = Trim(Replace(str, Chr(10), ""))
      c = "."
      If str = "solution" Then ml.Delete: sol# = sol# + 1: c = "+"
      If str = "<span style=""color: #ff0000"">deleted</span> question" Then ml.Delete: del# = del# + 1: c = "-"
      If str = "<span style=""color: #ff0000"">deleted</span> article" Then ml.Delete: del# = del# + 1: c = "-"
      Debug.Print c;
    End If
  Next
  
  Debug.Print Chr(13) & "Q: " & q# & "   Solved: " & sol# & "   Deleted: " & del#
  
  Web.Quit
  Set Web = Nothing
  
End Sub
                                    
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:

Select allOpen in new window


To use the code, I recommend to create a toolbar button, and assign the macro call to it. I have created this one for Outlook 2003:
 
--Article---Button..PNG
  • 437 bytes
  • My Button layout
My Button layout


The macro uses the InternetExplorer control to request a "printer friendly" version of pages. This is faster and contains less "clutter" then the usual views, and eases the parsing of the received HTML code.
Each page then is parsed for the question (or article) header, which tells us if it is closed or deleted.

After all (selected) mails have been processed, the debugger output presents a summary of the amount of questions processed, and how many of them were solved or deleted. You will see that only in the Direct Window of the VBA Editor, which you can switch on by pressing Ctrl-G.


"Obvious" Improvements

This macro uses an synchronous approach, processing  only one question at any time. It could have been done asynchronous, by using more than one IE (or IE Tab), and corresponding Event handlers, processing a shared queue. The result could be a "multi-threaded" processing of more than one question in-parallel.
I have to admit I tried that, but it is too complex because of the limitations Outlook, VBA and the InternetExplorer Events impose. For example you can't get DocumentComplete Events for each tab if using a tabbed browser – only the first tab's events are catched. And changing that requires to use one browser per question, and one event handler per browser – which again requires you to have a static setup of those. Feasible, but cumbersome.

It would be great if you could limit the amount of data retrieved for displaying a page. As-is, the code has to retrieve the full printer-friendly rendered thread, just to read the top let's say 500 bytes.
    Asked On
    2011-04-23 at 15:56:09ID5297
    Tags

    Outlook

    ,

    EE notification mails

    ,

    mail processing

    Topic

    Outlook Groupware Software

    Views
    1794

    Comments

    Author Comment

    by: Qlemo on 2012-02-05 at 04:11:04ID: 41995

    With EE v.10 this Add-On stopped working (as expected). Since I will (probably) have to switch to read XML streams instead of the printer-friendly page, getting it working again might last a while.

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Join Experts Exchange Today

    Gain Access to all our Tech Resources

    Get personalized answers

    Ask unlimited questions

    Access Proven Solutions

    Search 3.2 million solutions

    Read In-Depth How-To Guides

    1000+ articles, demos, & tips

    Watch Step by Step Tutorials

    Learn direct from top tech pros

    And Much More!

    Your complete tech resource

    See Plans and Pricing

    30-day free trial. Register in 60 seconds.

    Loading Advertisement...

    Top Outlook Experts

    1. apache09

      663,644

      Sage

      2,168 points yesterday

      Profile
      Rank: Genius
    2. alanhardisty

      170,946

      Guru

      0 points yesterday

      Profile
      Rank: Genius
    3. demazter

      131,854

      Master

      0 points yesterday

      Profile
      Rank: Genius
    4. chris_bottomley

      109,375

      Master

      2,800 points yesterday

      Profile
      Rank: Genius
    5. thinkpads_user

      95,624

      Master

      750 points yesterday

      Profile
      Rank: Genius
    6. Rajkumar-MCITP

      89,780

      Master

      0 points yesterday

      Profile
      Rank: Guru
    7. l33tf0b

      83,091

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    8. BlueDevilFan

      73,191

      Master

      50 points yesterday

      Profile
      Rank: Savant
    9. jjmck

      66,336

      Master

      0 points yesterday

      Profile
      Rank: Genius
    10. Neilsr

      61,466

      Master

      0 points yesterday

      Profile
      Rank: Genius
    11. amitkulshrestha

      61,377

      Master

      0 points yesterday

      Profile
      Rank: Genius
    12. jcimarron

      49,232

      0 points yesterday

      Profile
      Rank: Genius
    13. ve3ofa

      46,002

      0 points yesterday

      Profile
      Rank: Genius
    14. dlmille

      45,200

      0 points yesterday

      Profile
      Rank: Genius
    15. akicute555

      44,979

      10 points yesterday

      Profile
      Rank: Wizard
    16. Anuroopsundd

      44,529

      0 points yesterday

      Profile
      Rank: Sage
    17. HendrikWiese

      40,896

      2,000 points yesterday

      Profile
      Rank: Sage
    18. Exchange_Geek

      37,449

      0 points yesterday

      Profile
      Rank: Sage
    19. jordannet

      36,757

      0 points yesterday

      Profile
      Rank: Wizard
    20. acbrown2010

      34,652

      0 points yesterday

      Profile
      Rank: Genius
    21. diverseit

      34,600

      0 points yesterday

      Profile
      Rank: Guru
    22. WORKS2011

      32,775

      0 points yesterday

      Profile
      Rank: Guru
    23. e_aravind

      31,941

      0 points yesterday

      Profile
      Rank: Genius
    24. JBlond

      31,700

      0 points yesterday

      Profile
      Rank: Sage
    25. limjianan

      30,910

      0 points yesterday

      Profile
      Rank: Genius

    Hall Of Fame