To save individual emails from Microsoft Outlook to .msg format you can simply select required emails and drag them to any folder or to your desktop. The only issue I have with this approach is that each .msg file name is made up of only of email subject and sometimes a number (to avoid conflicts on emails with the same subject line). File created and modified dates are the export date. All this means that there is no way to arrange emails in date sent / received order. This may be not a problem is you have only couple of emails to export, but with larger number of emails it quickly becomes very disorganised.

I recently came across a small neat VBS Macro that I found on www.slipstick.com. When run it exports selected emails into .msg files and adds date / time received as a prefix to the file names.
For example, where you would normally have email with file name: Phone Call.msg, now you have 2014.12.21-14.12.04 - Phone Call.msg.

 

 

Bellow is the code I used. This is almost exactly the same code as in the above linked website, I just changed date/time formatting to make it more human readable.


Option Explicit
Public Sub SaveMessageAsMsg()
Dim oMail As Outlook.MailItem
Dim objItem As Object
Dim sPath As String
Dim dtDate As Date
Dim sName As String
Dim enviro As String
enviro = CStr(Environ("USERPROFILE"))
For Each objItem In ActiveExplorer.Selection
If objItem.MessageClass = "IPM.Note" Then
Set oMail = objItem
sName = oMail.Subject
ReplaceCharsForFileName sName, "-"
dtDate = oMail.ReceivedTime
sName = Format(dtDate, "yyyy.mm.dd", vbUseSystemDayOfWeek, _
vbUseSystem) & Format(dtDate, "-hh.nn.ss", _
vbUseSystemDayOfWeek, vbUseSystem) & " - " & sName & ".msg"
sPath = enviro & "\Documents\"
Debug.Print sPath & sName
oMail.SaveAs sPath & sName, olMSG
End If
Next
End Sub

Private Sub ReplaceCharsForFileName(sName As String, _
sChr As String _
)
sName = Replace(sName, "'", sChr)
sName = Replace(sName, "*", sChr)
sName = Replace(sName, "/", sChr)
sName = Replace(sName, "\", sChr)
sName = Replace(sName, ":", sChr)
sName = Replace(sName, "?", sChr)
sName = Replace(sName, Chr(34), sChr)
sName = Replace(sName, "<", sChr)
sName = Replace(sName, ">", sChr)
sName = Replace(sName, "|", sChr)
End Sub

Emails are saved in "Documents" folder inside user's profile. I.e. C:\Users\<user.name>\Documents. This is not necessary the same as user's "My documents" folder determined by settings in Libraries or Group Policy.

Another thing to note is that this macro will override files with the same name. This means that if you have multiple emails with the same subject line that were sent / received at exactly the same time (within 1 second), only one of these emails will be saved. In most cases such emails would be duplicates anyway, but you may want to check if number selected and exported emails matches.

2015.01
Outlook 2010

4 comments

  • Hello Arunas

    In the past I would use the .pst format until my file became to large in combination of my computer crashing and I ended up corrupting the .pst files and losing thousands of emails,  I search for an alternative option and found a macro that would convert/move/export (whatever you want to call it) all my emails, including the folder structure directly to my hard drive.  I had reach out to the developer who helped me add time format (YYYYMMDD-HHMM) with AM/PM.  I did that for a while but then realized, I had no clue who the emails came or went to.  So we then added the "Senders" name for the outbox folder and for the sent folder the "Recipient" name.  This also worked for a while until I discovered that no all emails were be save, sometime none at all, while other emails were being converted to a "file" that could not be opened.  I had reached back out to that developer who could not provide insight as to why this was occurring.  I have gone through and done another huge archiving of my emails and decided to see if there was something newer / better. I came across your site in my search of archiving emails onto my harddrive via .msg. I wish I could write my own code (should have paid more attention in school) but I not a complete novice.  If this macro does not have all the features I am looking for, would you be able to help with its modification.  I would pay you for your time?  Thank you.

    • I haven't used this script in ages, so not sure if it still works in the latest versions of Outlook. Where is your mailbox hosted? Can't you leave the emails on the server? If export is required, PST would be an easier option. Sure, they can get corrupted, but you should always have a backup regardless of what file formats you use.

      • Hi there

        My email is Gmail but then I have an account hosted by Omnis.  I also have a few various accounts that are getting cluttered and want to back those up.  The problem with ".pst" is that its a file and would need to reload back into outlook to view the emails/folder structure.  Moving them to my hard drive allows me to delete the emails from the server, keeping the email structure and be able to view each email along with sort & search.  Basically working "offline".

        • Yes, PST needs to be loaded in Outlook, but I think it satisfies all other requirements you have: working offline, keeping folder structure, searching, deleting emails from the server. 

Leave your comment

In reply to Some User
Captcha Image