Getting Google Desktop to index Outlook's Deleted Items folder
I've recently discovered the joys of running Google Desktop on my machine, primarily as a really fast way to search all my emails in Outlook. But there's one issue I've had that nobody seems to have an answer for - Google Desktop will not index the 'Deleted Items' folder in Outlook. You can configure it to hold items in the search index even after they've been deleted, but that's not the same. If you receive an email and delete it or move it to 'Deleted Items' before Google Desktop has a chance to index it, it will never appear in your search results.
So I took it upon myself to devise a solution to this. This soution was developed under Windows XP with Outlook 2000 (Yes, some big corporates still run this!). It basically involves creating a new folder called 'Archived Deleted Items' and ensure that any mail you delete will go here rather than the default 'Deleted Items' folder. Google Desktop will see this just as any normal Outlook folder and will index it.
- Create a folder called "Deleted Items Archived" as a subfolder of "Inbox".
- Create a text file called archiveDeletedMail.bat with the following contents:
cscript archiveDeletedMail.vbs
- Create a text file called archiveDeletedMail.vbs with the below contents. This VB Script will basically attach to your existing authenticated Outlook session and, every few minutes, move all mail from "Deleted Items" to "Deleted Items Archived":
Set out = WScript.StdOut
while true
Set mapiSession = WScript.CreateObject("MAPI.Session")
'Piggyback on current MAPI Session (requires Outlook to be running)
mapiSession.Logon "", "", False, False, 0, False ', ServerName & vbLf & UserName
'4 = DeletedItems, 1 = Inbox
Set folderInbox = mapiSession.GetDefaultFolder(1)
Set folderDeletedItems = mapiSession.GetDefaultFolder(4)
'Get "Deleted Items Archived" folder
If Not folderInbox.Folders Is Nothing Then 'there are child folders
Set inboxSubfolders = folderInbox.Folders
Set objOneSubfolder = inboxSubfolders.GetFirst
While Not objOneSubfolder Is Nothing ' loop through all children
If objOneSubfolder.Name = "Deleted Items Archived" then
Set folderDeletedItemsArchived = objOneSubfolder
Set objOneSubfolder = Nothing
Else
Set objOneSubfolder = inboxSubfolders.GetNext
End If
Wend
End If
'Now we have Deleted Items and Deleted Items Archive.
'So we move messages from one to the other.
If Not folderDeletedItems.Messages Is Nothing Then 'there are messages
Set deletedMessages = folderDeletedItems.Messages
Set objOneDeletedMessage = deletedMessages.GetFirst
While Not objOneDeletedMessage Is Nothing ' loop through all children
out.write(now() & " - Moving Message: """ & objOneDeletedMessage.Subject & _
""" to Folder: " & folderDeletedItemsArchived.Name & vbCRLF)
objOneDeletedMessage.MoveTo(folderDeletedItemsArchived.ID)
Set objOneDeletedMessage = deletedMessages.GetNext
Wend
End If
'Clean up
set folderInbox = Nothing
set folderDeletedItems = Nothing
set inboxSubfolders = Nothing
set objOneSubfolder = Nothing
set folderDeletedItemsArchived = Nothing
set objOneDeletedMessage = Nothing
set deletedMessages = Nothing
set inboxSubfolders = Nothing
mapiSession.Logoff
Set mapiSession = Nothing
'Wait for next execution
WScript.Sleep(600000)
wend - Whenever you run Outlook, run archiveDeletedMail.bat afterwards.
Unfortunately, the console window from this script will always stay open, but to me this is much less of an inconvenience than not having my Deleted Items folder indexed!
Update: Oh, if you really don't want to see the console window from this script always staying open (and you work in a corporate that doesn't disable Windows Task Scheduler in it's SOE!) you could probably remove the"while" and "wend" lines from the above script and configure it as a scheduled task to run (minimised) every X minutes.
Comments
Leave a comment
Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
Comment by Corne [Visitor] — 11/14/11 @ 17:24