"Export" Outlook mail to Gmail

I am really beginning to like Gmail, and find myself opening the browser to check mail instead of Outlook. I miss an import function in Gmail though. It would be nice if I could upload a .pst file to Gmail. Instead I made this little VB script that runs though my inbox and forwards every single mail to my Gmail account (and of course a filter to automatically archive and categorize it). It takes a while to process a large inbox, but the pause is required to avoid flodding the SMTP server.

Put this in ThisOutlookSession:

Sub ProcessInbox() Dim ns As NameSpace Set ns = ThisOutlookSession.Session Dim ib As MAPIFolder Set ib = ns.GetDefaultFolder(olFolderInbox) Dim item As MailItem For Each item In ib.Items Dim fwd As MailItem Set fwd = item.Forward fwd.Recipients.Add "[INSERT ACCOUNT NAME]+import@gmail.com" fwd.Subject = Replace(fwd.Subject, "FW: ", "", 1, 1) fwd.Send While ns.GetDefaultFolder(olFolderOutbox).Items.Count > 5 Dim i As Integer For i = 0 To 1000 DoEvents Sleep 15 Next i Wend Next End Sub

And this in a module:

Public Declare Sub Sleep Lib "kernel32″ (ByVal dwMilliseconds As Long)

m@kli.dk @klinkby RSS feed  GitHub