Jaffirahamed
New Member
- Joined
- Feb 21, 2024
- Messages
- 3
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- Mobile
Hi Gurus,
Just joined this forum.
Good day to you all.
I have a folder in outlook where all the email messages from the other team will fall in to that folder. i want the VBA code that capture all the messages one by one in excel sheet.
The first slide is sample email message with the fields with column order number.
The second slide, the capture results should come same as like the table to the excel sheet. I have attached sample sheets for your reference.
I hope my question is clear to understand.
Thanks in advance.
I have a below where it capture the TO, subject and received but not items in body like String and table contents, i have attached sample sheet for your reference. Let me know if you need anything else.
Just joined this forum.
Good day to you all.
I have a folder in outlook where all the email messages from the other team will fall in to that folder. i want the VBA code that capture all the messages one by one in excel sheet.
The first slide is sample email message with the fields with column order number.
The second slide, the capture results should come same as like the table to the excel sheet. I have attached sample sheets for your reference.
I hope my question is clear to understand.
Thanks in advance.
I have a below where it capture the TO, subject and received but not items in body like String and table contents, i have attached sample sheet for your reference. Let me know if you need anything else.
VBA Code:
Sub getfolderitems()
On Error GoTo ErrHandler
' Set Outlook application object.
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objNSpace As Object ' Create and Set a NameSpace OBJECT.
' The GetNameSpace() method will represent a specified Namespace.
Set objNSpace = objOutlook.GetNamespace("MAPI")
Dim myFolder As Object ' Create a folder object.
Set myFolder = objNSpace.GetDefaultFolder(olFolderInbox)
Dim otherFolder As Object
Set otherFolder = myFolder.Folders("Fedx Request")'Insert subfolder'
Dim objItem As Object
Dim iRows, iCols As Integer
iRows = 2
' Loop through each item in the folder.
For Each objItem In otherFolder.Items
If objItem.Class = olMail Then
Dim objMail As Outlook.MailItem
Set objMail = objItem
Cells(iRows, 1) = objMail.SenderEmailAddress
Cells(iRows, 2) = objMail.To
Cells(iRows, 3) = objMail.Subject
Cells(iRows, 4) = objMail.ReceivedTime
End If
iRows = iRows + 1
Next
Set objMail = Nothing
' Release.
Set objOutlook = Nothing
Set objNSpace = Nothing
Set otherFolder = Nothing
ErrHandler:
Debug.Print Err.Description
End Sub