Parse outlook email to excel

There are several ways to parse Outlook emails to Excel, depending on your specific requirements and the version of Outlook you are using. Here are a few methods:

Method 1: Using Outlook's built-in feature

  1. Open Outlook and go to the folder containing the emails you want to export.
  2. Select the emails you want to export by checking the boxes next to them.
  3. Right-click on the selected emails and choose "Export to a file" from the context menu.
  4. In the "Export to a file" dialog box, select "Comma Separated Values (CSV)" as the file format.
  5. Choose a location to save the file and click "Export".
  6. Open the exported CSV file in Excel.

Method 2: Using VBA Macro

  1. Open Outlook and go to the Visual Basic Editor by pressing Alt + F11 or by navigating to Developer > Visual Basic in the ribbon.

  2. In the Visual Basic Editor, insert a new module by clicking "Insert" > "Module" or by pressing Alt + F11.

  3. Paste the following code into the module:

    Sub ExportEmailsToExcel()
     Dim olApp As New Outlook.Application
     Dim olNamespace As Outlook.Namespace
     Dim olFolder As MAPIFolder
     Dim olItems As Items
     Dim i As Integer
     Dim j As Integer
     Dim strEmail As String
     Dim strSubject As String
     Dim strBody As String
     Dim strFrom As String
     Dim strTo As String
     Dim strCC As String
     Dim strBCC As String
     Dim strDate As String
     Dim strFile As String
    
     Set olNamespace = olApp.GetNamespace("MAPI")
     Set olFolder = olNamespace.GetDefaultFolder(olFolderInbox)
     Set olItems = olFolder.Items
    
     strFile = "C:\Emails.csv"
     Open strFile For Output As #1
    
     For i = 1 To olItems.Count
         strEmail = ""
         strSubject = ""
         strBody = ""
         strFrom = ""
         strTo = ""
         strCC = ""
         strBCC = ""
         strDate = ""
    
         For j = 1 To olItems(i).Fields.Count
             Select Case olItems(i).Fields(j).Name
                 Case "Subject"
                     strSubject = olItems(i).Fields(j).Value
                 Case "Body"
                     strBody = olItems(i).Fields(j).Value
                 Case "From"
                     strFrom = olItems(i).Fields(j).Value
                 Case "To"
                     strTo = olItems(i).Fields(j).Value
                 Case "CC"
                     strCC = olItems(i).Fields(j).Value
                 Case "BCC"
                     strBCC = olItems(i).Fields(j).Value
                 Case "Received"
                     strDate = olItems(i).Fields(j).Value
             End Select
         Next j
    
         strEmail = strEmail & strFrom & "," & strTo & "," & strCC & "," & strBCC & "," & strSubject & "," & strBody & "," & strDate & vbCrLf
    
         Print #1, strEmail
     Next i
    
     Close #1
     Set olItems = Nothing
     Set olFolder = Nothing
     Set olNamespace = Nothing
     Set olApp = Nothing
    End Sub
  4. Run the macro by clicking "Run" > "ExportEmailsToExcel" or by pressing F5.

  5. The macro will export the emails to a CSV file named "Emails.csv" in the specified location.

Method 3: Using a third-party add-in

There are several third-party add-ins available that can help you parse Outlook emails to Excel, such as:

These add-ins can be downloaded and installed from the internet, and then configured to export Outlook emails to Excel.

Method 4: Using a script

You can also use a script to parse Outlook emails to Excel. For example, you can use a PowerShell script to export Outlook emails to Excel. Here is an example script:

# Import the Outlook COM object
Add-Type -AssemblyName Microsoft.Office.Interop.Outlook

# Set the path to the Outlook profile
$profilePath = "C:\Path\To\Outlook\Profile"

# Set the path to the Excel file
$excelFile = "C:\Path\To\Excel\File.xlsx"

# Create a new Excel file
$excel = New-Object -ComObject Excel.Application
$workbook = $excel.Workbooks.Add()
$worksheet = $workbook.Sheets.Item(1)

# Loop through the emails in the Outlook profile
foreach ($email in (Get-Mailbox -Identity "YourEmailAccount" -Profile $profilePath).Inbox.Items) {
    # Get the email properties
    $from = $email.From
    $subject = $email.Subject
    $body = $email.Body
    $date = $email.ReceivedTime

    # Add the email properties to the Excel worksheet
    $worksheet.Cells.Item(1, 1) = $from
    $worksheet.Cells.Item(1, 2) = $subject
    $worksheet.Cells.Item(1, 3) = $body
    $worksheet.Cells.Item(1, 4) = $date

    # Increment the row number
    $rowNumber = 1
    $worksheet.Cells.Item($rowNumber, 1) = $from
    $worksheet.Cells.Item($rowNumber, 2) = $subject
    $worksheet.Cells.Item($rowNumber, 3) = $body
    $worksheet.Cells.Item($rowNumber, 4) = $date
    $rowNumber++
}

# Save the Excel file
$workbook.SaveAs($excelFile)

# Close the Excel file
$workbook.Close()
$excel.Quit()

This script uses the Outlook COM object to connect to the Outlook profile, and then loops through the emails in the inbox. It extracts the email properties (from, subject, body, and date) and adds them to an Excel worksheet. Finally, it saves the Excel file to the specified location.

Note that this script requires the Outlook COM object to be installed on the system, and also requires the Excel COM object to be installed on the system.