- Community Pick
- Experts Exchange Approved
- Editor's Choice
The "Framework" that I present below has been tested with Outlook 2003, 2007 and 2010. Since VBA Macros are used, you might have to allow macro execution when starting Outlook.
We utilize so-called User Properties, which have some particularities, but are great for holding additional user-definied content.
I have not tested the code provided if it works flawlessly with HTML mails, only with plain text.
Since the mail content and subject can change at any time, it might not work anymore after new releases were published.
- 1
Basics – Different types of email you will receive, and what to do with them
Expert Alert: …
A new question your filter has trapped. This is usually the first mail you get, if you have set up filters with alerts.
Neglected Question Alert: …
A question which is neglected. You are Designated Expert in one of the zones, and this message is not depending on any filter you have set up.
If you receive this, you won't need the "Expert Alert" anymore, so the code will delete that one, if found. (Note that the subject line has two spaces after the colon.)
Comment Added: …
An Expert has posted to a question you have contributed to or subscribed. That might be interesting for you, as it could bring new insight or alternatives, or pose additional questions. Some good solutions originate in Experts working together, improving successively each other recommendations.
If you get a new "Comment Added" mail while having other emails of the same subject, it is time to decide what you want to keep:
Are you more interested in the first comment after your own, so you can click on the link and directly jump to that comment, and than read the remaining thread to keep up with everything?
Is it more important to always have the newest post in your inbox, so you know if there is an ongoing discussion?
Or aren't you interested at all in this, so it should be dismissed?
Anyway, "Expert Alerts" and "Neglected Question Alerts" are moot now – you have subscribed, probably posted a comment yourself; either way, you know already about that question.
Author Comment Added: …
The Author of the question has posted. This is most important, of course, because usually answers (or more questions!) arise from that.
An Author Comment can be handled like an Expert Comment; that is, only the newest or oldest need to be kept (see above).
Or an Author Comment is more important than any other comment, and replace all other earlier mails which are not Author Comments – or even those.
Good Answer! … or Good Assist! …
This are good news! You have received points.
After having received this mail you will usually not want to keep any other mail regarding the same topic, so the code will remove them. I recommend to always open the question to see which other posts have been accepted, whether the correct answer(s) have been selected, and so on.
Answer Accepted: … or Points Split: …
Not good. The question is closed, and you do not get points.
The tag (and some other info) is added as a so-called User Property – something I have to explain in another article, because it is a too complex matter to keep discuss that here.
The following mails are more difficult, as they do not contain the referred question (or article) in the subject. Hence the email body needs to be parsed for keywords, and those replace the original subject:
Congratulations, you have earned a new rank!
Great, you really got (another) rank!
When receiving, the code should automatically generate the corresponding certificate, print it out, and open a bottle of champagne. Just kidding ;-).
What the code really does is parsing rank (Master, Guru etc.) and Zone out of the body to fill that into the subject.
A question you participated in will be deleted in four days
Either the Asker has decided to remove the question, or a Cleanup Volunteer did because of lack of recent posts.
You should review this question in case you want to object to the deletion.
A question you participated in will be closed in four days
The Asker, a Moderator or Zone Advisor has started the "Auto-Close" with 4 days grace period.
Since it is totally unclear if you will receive any points, you should review the question for details.
A different case is if you get mail about an article you wrote. The only processed mail besides article comments is:
"Please review your article"
A Page Editor has set your article to Author Review, and you need to return to the article to continue with editing.
In addition to the above (processed) mails, you will get the following ones, which are currently ignored by the code.
Objection Posted: …
The question was in the process of being deleted or closed, with a grace period of 4 days, and somebody has objected to that. Since this requires a reaction from your side, no particular automation is applied.
Designated Expert Zones Added
You have just earned enough points in a zone for becoming a Designated Expert in it, and you have not opted out to the Designated Expert feature as a whole. Since this means you get more "NQ" alerts though you might not be that confident in your related knowledge, removing the new zone in your Member Profile could be a good idea.
Those article-related mails (talking about points you have earned) are not processed either, because you won't get that many of them presumably:
You've Got Bonus Points!
Congratulations! Your article has been published
Congratulations! Your Article was used in a Solution.
Congratulations! Your Article has been EE Approved
Congratulations! Your Article is an Editor's Choice
With the framework shown it should be easy to implement that yourself, if you like.
- 2
The Outcome by Example
Note: I will show the Tag column here in square brackets – just to visualize. In fact tags are not stored with square brackets.
The VBA code processes emails by:
- matching the subject against a header (e.g. "Author Comment Added: ")
- if found, remove it
- if found, fill the Tag column ("[Author]")
- if found, search and remove mails not needed anymore ("Expert Alert: " resp. "[New]"), or delete this new mail if another email to be kept has been received already ("Comment Added: " resp. "[Expert]").
Applied to a simplified example:
21.12.2010 22:00:00 Neglected Question Alert: Example Question
will first result in
21.12.2010 22:00:00 [NQ] Example Question
and finally (since a [NQ] triggers removal of [New])
A more complex example – having heavy activity:
Let's assume we are contributing to a question with several other Experts, and there is a lot of traffic.
21.12.2010 09:00:01 Expert Alert: Completely unrelated Question
21.12.2010 10:00:00 Comment Added: Why you should use EE
21.12.2010 10:01:00 Author Comment Added: Why you should use EE
21.12.2010 10:01:30 Comment Added: Why you should use EE
21.12.2010 10:01:35 Comment Added: Why you should use EE
21.12.2010 10:05:00 Author Comment Added: Why you should use EE
Among many others not shown here, we are only interested in the "Why you should use EE" one. We cannot sort simply for it, since we would get all "Author Comment Added" first, then "Comment Added", and last "Expert Alerts". The code that changes the Subject lines makes it easier to keep track:
21.12.2010 09:00:01 [New] Completely unrelated Question
21.12.2010 10:00:00 [Expert] Why you should use EE
21.12.2010 10:01:00 [Author] Why you should use EE
21.12.2010 10:01:30 [Expert] Why you should use EE
21.12.2010 10:01:35 [Expert] Why you should use EE
21.12.2010 10:05:00 [Author] Why you should use EE
That is looking much better, isn't it? We could just sort on the Subject line, and have a better overview. But the code does more. Again the [New] one is removed – we are contributing (or subscribed), and that mail is not needed anymore. Further, we don't need the whole bunch of emails, one or two are sufficient to know either Experts or the Author (or both) have commented. The code will now keep the oldest of each comment type (Expert and Author):
21.12.2010 10:00:00 [Expert] Why you should use EE
21.12.2010 10:01:00 [Author] Why you should use EE
If we change the constant optKeepOld to false (I'll show the code further below), we will see the most recent post of each type:
21.12.2010 10:01:35 [Expert] Why you should use EE
21.12.2010 10:05:00 [Author] Why you should use EE
If the asker accepts one of our answers with 500 points and grade "A", the incoming mail of
will result in
22.12.2010 05:00:00 [P: 2,000 A] Why you should use EE [P: 2,000 A]
That is, all comment type emails are removed.
In case you do not get the "Good Answer" mail, but a "… will be closed …" instead, the unprocessed mail leaves this:
21.12.2010 10:01:35 [Expert] Why you should use EE
21.12.2010 10:05:00 [Auhor] Why you should use EE
22.12.2010 05:00:00 A question you participated in will be closed in four days
and after being processed:
22.12.2010 05:00:00 [No pts] Why you should use EE
Again, all comments have been removed, leaving a single email.
- 3
Getting started
You can create rules based on the mail account (if you use a particular account), or the sender (noreply@experts-exchange
For the remainder of the article, I will call this folder "EE inbox". For testing purposes, you can setup a folder, and manually copy/move EE mails into it to see the result.
Import the code into the VBA Editor – press Alt-F11 to open that editor, open the "File" menu, and import the attached file (after renaming to *.cls).
Having created the rule, dedicated a folder for keeping EE mails, and importing the VBA code, you need to set a variable in the code to this folder. That folder is referenced in the Application_Startup macro, which contains code executed on startup of Outlook. I have provided three examples of how the complete path can look like:
(1) is your default inbox
(2) shows an example for providing a folder deeper into a folder tree
(3) uses an own PST file for EE
As soon as you have done that, you should call that macro – best just to position your cursor into it, and press F5.
Nothing more to do! If you have set this up as your "live" environment, incoming emails will be processed automatically. If you used a test folder, just move or copy some mails into that folder, and view the result.
- 4
The VBA Code
Coming back to the trigger code. As you have certainly seen it is "the core", where every action is initiated. First we make sure it is really a mail, and then we can apply our tests against it, by calling EESubj:
- removes the heading from the subject line
- looks if we have a dynamic tag (containing a percent sign), and hence need some more parsing to fill out the template; in that case we append the resulting tag to the subject, in all other cases this is not done (automatically).
- sets all User Properties we need (done in EESetRefInfo)
- takes care of removing this or any older email, if one with the same subject and any of the tags provided as forth parameter is found.
- returns true
Note: All tags are provided with square brackets for readability only. Tags are not stored that way (with exception when optionally appended to the subject), however it is much easier to detect the tags, and to search for them, this way.
Since the function returns a Boolean, you can do something like adding categories, moving to another folder, and so on. The code contains some examples.
You might have noticed that "%Points%", "%Bonus%" and "%Grade%" – that allows for inserting exactly that info, extracted from text found in the email body. Point info can have two appearances, either as "normal" points, or points with bonus from answering neglected questions. The wording in the body is different, and we do not know in advance if the email is about a neglected or "normal" question, so we have to parse for both.
Back to the trigger procedure. As we know, there are EE mails which do not contain anything about the subject matter in the subject line, like "Please review your article". To get those more informative, EEBody is called:
That one does almost the same as EESubj, but retrieves the question or article title from the body. That works as long as we have unique identifying keywords, which is luckily the case – at the moment, at least.
The other function used the same way, EERank, is not that much different, so I will not show the code. The parsing is bit more tricky, as we need to extract partitial info out of sentences.
There are some more (helper) procedures and functions, which I won't show here, since their implementation is not of much interest. However, three key routines are located at the bottom of the file I provided. I'll only discuss them in short:
allows to go thru your EE inbox again in chronological order, or thru a list of selected mails, in case the trigger has not been run on all mails. That will occur if too many mails come in at once, or the VBA code has been halted due to an error message or a recent VBA code edit. It might be a good idea to dedicate a button in your toolbar to this macro.
EEJump2URL
(see code below) uses the URL constructed on receive of the mail, and stored in one of the User Properties, to open that post in your default Web browser.
EEJumpNdel
is almost the same as EEJump2URL, but deletes the email in the same go. Useful for the Author/Expert comment type mails.
- 5
My Last Words
Further improvements, and tips for organizing better.
If you have different roles on EE, such as Expert and Page Editor, you might want to use separate folders for each role. As soon as you have understood how the code works, it should be easy to expand to using more than a single folder. The subroutines used are not bound to a particular folder, with exception of the trigger code, and I have already supplied an example trigger definition for using a separate folder for PE work.
I took care about being very flexible with the tags. For example, if you want not to differ between Author and Expert comments, just use the same tag for both. If you want to introduce or change tags – no problem.
Programmatically moving a post which will need to be considered later again (e.g. all New and NQ alerts in one folder, comments in another) are very difficult to handle. This is because the simple search feature used does support searching only in a single folder; the more sophisticated Advanced Search, which would allow for parsing subfolders, is asynchronous and way too complex to rectify its usage here.
To overcome the "single inbox folder" restriction, I use rules to assign color flags to different mail types. My NQ alerts are yellow, new questions are blue, aso. Then I have set up filter/search favourites for each of those, which allows me to look at new questions only, or work on comments first. Instead of filter favourites the grouping feature can be used – but expanding/collapsing is not that useful, IMO.
Article and question comments are processed the same, and hence look the same – with one exception: The "Reference" user property start with an A instead of a Q. I use that by just showing the first letter of it in my Outlook views. The following screenshots show that using search favourites and custom views help much:
by: tigermatt on 2010-12-28 at 11:27:47ID: 22521