Hi
I have 500 .msg files i want to pull Subject, Body,Email Id From, Email Id To,
Please tell me how to do this
I have macro but that macro pull only Subject line please tell me rest data how to pull in excel
I have 500 .msg files i want to pull Subject, Body,Email Id From, Email Id To,
Please tell me how to do this
I have macro but that macro pull only Subject line please tell me rest data how to pull in excel
Code:
Option Explicit
Sub GetSubjectLines()
Dim olA As Object
Dim aPaths() As String 'paths to *.msg files
Dim vSubjects() As Variant 'list of subjects
Dim vSelItems As Variant 'to get selected items
Dim i As Long
Dim rDest As Range 'where Subject lines will be written
Set olA = CreateObject("Outlook.Application")
Set rDest = Range("B1")
'Select the files to process
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Add "Messages", "*.msg", 1
.FilterIndex = 1
If .Show = -1 Then
ReDim aPaths(0 To .SelectedItems.Count - 1)
For i = 0 To .SelectedItems.Count - 1
aPaths(i) = .SelectedItems(i + 1)
Next i
End If
End With
Application.ScreenUpdating = False
rDest.EntireColumn.Clear
With rDest(1, 1)
.Value = "Subjects"
.Font.Bold = True
End With
ReDim vSubjects(1 To UBound(aPaths) + 1, 1 To 1)
For i = 0 To UBound(aPaths)
vSubjects(i + 1, 1) = olA.CreateItemFromTemplate(aPaths(i)).Subject
Next i
Set rDest = rDest.Offset(rowoffset:=1).Resize(rowsize:=UBound(vSubjects))
rDest = vSubjects
rDest.EntireColumn.AutoFit
Application.ScreenUpdating = True
Set olA = Nothing
End Sub