Exporting Outlook emails with messageID to CSV

Any way to export Outlook emails to CSV with message IDs?

3rd Party software suggestions or anything

Thank you,
itmtiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

itmtiAuthor Commented:
Need to export Sent Items with MessageIDs to csv.


We exported via Exhange, we just need to correlate and figure out if all the emails that left outlook actually hit Exchange.
AmitIT ArchitectCommented:
For that you check Exchange tracking logs.
itmtiAuthor Commented:
We did check exchange tracking logs and exported,   I am asking specifically for Outlook export of emails with messageID from header.

Thanks
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

AmitIT ArchitectCommented:
I don't see any such option to export it. You need to open header info for each message and copy it.
Will SzymkowskiSenior Solution ArchitectCommented:
I have never tried this but apparently  you can do this with the Exchange Web Service API. See the link before for reference.
https://social.technet.microsoft.com/forums/windowsserver/en-US/2b116f1b-30b7-4d14-8d5e-e4832920ad2d/export-email-header-information-via-powershell

Will.
omgangIT ManagerCommented:
@itmti, are you familiar with VBA coding in Outlook?
This is a sample function to get the messageID of messages in the Outlook Inbox.  If this is what you're looking for it will be relatively simple to expand it to send output to a CSV file.
OM Gang

Public Function CopyItem()
On Error GoTo Err_CopyItem

    Dim olNS As NameSpace
    Dim olFolder As MAPIFolder
    Dim olMsg As MailItem
    Dim olPropertyAccessor As Outlook.PropertyAccessor
    Dim intCount As Integer
    
    intCount = 0
    
    Set olNS = Outlook.GetNamespace("MAPI")
    'Set olFolder = olNS.PickFolder   'we can use this to present the user with a dialogue box to select the folder they want to process
    Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
    
    For Each olMsg In olFolder.Items
        If intCount = 10 Then Exit For
        Debug.Print olMsg.Subject
        Debug.Print olMsg.ItemProperties.Class
        Set olPropertyAccessor = olMsg.PropertyAccessor
        Debug.Print "PR_INTERNET_MESSAGE_ID", olPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x1035001E")
            
        intCount = intCount + 1
    Next

Exit_CopyItem:
    Set olPropertyAccessor = Nothing
    Set olDestFolder = Nothing
    Set olMsg = Nothing
    Set olFolder = Nothing
    Set olNS = Nothing
    Exit Function
    
Err_CopyItem:
    MsgBox Err.Number & ", " & Err.Description, , "Error"
    Resume Exit_CopyItem
    
End Function

Open in new window

itmtiAuthor Commented:
@omgang  -  very limited, but thats what everything pointing me to.

Any suggestion on your code how to export, I ran this in VBA on Outlook but no output or anything.

Thank you
omgangIT ManagerCommented:
To see the output you need to open/view the Immediate Window in the Outlook VBE.  See the View menu in the VBE or key in Ctrl+G in the VBE to display it.

I'll work on adding code to output to CSV.
OM Gang
itmtiAuthor Commented:
Ok, so far going well, able to see in the Immediate view.

Would be great for any help with export to CSV
itmtiAuthor Commented:
@omgang,  

your script exported what we need, just missing date of email and email was sent to.
Could you please suggestion or adjust the code to add that?

Thank you in advance
!
itmtiAuthor Commented:
@omgang

Please ignore no need for date, but message-id looks good.

Having some issues with picking specific folder, if my folder named expample:  Test
I want everything from that Test folder exported to that Immediate view that would work, i would just clean it up in Excel.

Thank you
omgangIT ManagerCommented:
Sorry, I've been in meetings.  To process a specific folder you need to make this simple change


    Set olFolder = olNS.PickFolder   'we can use this to present the user with a dialogue box to select the folder they want to process     <---- uncomment this line
    'Set olFolder = olNS.GetDefaultFolder(olFolderInbox)   <---- comment out this line

Also, you need to remove my count limitation so that the function processes all messages.
    For Each olMsg In olFolder.Items
        'If intCount = 10 Then Exit For   <---- comment out this line so that the For Next loop doesn't exit after 10 iterations

Public Function CopyItem()
On Error GoTo Err_CopyItem

    Dim olNS As NameSpace
    Dim olFolder As MAPIFolder
    Dim olMsg As MailItem
    Dim olPropertyAccessor As Outlook.PropertyAccessor
    Dim intCount As Integer
    
    intCount = 0
    
    Set olNS = Outlook.GetNamespace("MAPI")
    Set olFolder = olNS.PickFolder   'we can use this to present the user with a dialogue box to select the folder they want to process
    'Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
    
    For Each olMsg In olFolder.Items
        'If intCount = 10 Then Exit For
        Debug.Print olMsg.Subject
        Debug.Print olMsg.ItemProperties.Class
        Set olPropertyAccessor = olMsg.PropertyAccessor
        Debug.Print "PR_INTERNET_MESSAGE_ID", olPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x1035001E")
            
        intCount = intCount + 1
    Next

Exit_CopyItem:
    Set olPropertyAccessor = Nothing
    Set olDestFolder = Nothing
    Set olMsg = Nothing
    Set olFolder = Nothing
    Set olNS = Nothing
    Exit Function
    
Err_CopyItem:
    MsgBox Err.Number & ", " & Err.Description, , "Error"
    Resume Exit_CopyItem
    
End Function

Open in new window


OM Gang

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itmtiAuthor Commented:
Thank you!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Software

From novice to tech pro — start learning today.