I am working on a project where I can send a text to a list of phone numbers (through outlook) and now, I want to import the replies into a new worksheet automatically. I found and edited some code that seems to work for importing emails from a specific folder, but I cannot figure out how to get it to import emails from the inbox. Any help would be greatly appreciated. Here is the code I have:
Sub ImportEmails()
Dim olA As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olF As Outlook.MAPIFolder
Dim olM As Outlook.MailItem
Dim lrow As Long
Set olA = New Outlook.Application
Set olNS = olA.GetNamespace("MAPI")
'Select the folder number here where the first one is 0
Set olF = olNS.Folders.Item(0)
lrow = 1
For Each olM In olF.Items
With Sheets(Sheet3)
.Cells(lrow, 1) = olM.SenderName
.Cells(lrow, 2) = olM.Subject
.Cells(lrow, 3) = olM.Body
lrow = lrow + 1
End With
Next
Set olM = Nothing
Set olF = Nothing
Set olNS = Nothing
Set olA = Nothing
End Sub
Sub ImportEmails()
Dim olA As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olF As Outlook.MAPIFolder
Dim olM As Outlook.MailItem
Dim lrow As Long
Set olA = New Outlook.Application
Set olNS = olA.GetNamespace("MAPI")
'Select the folder number here where the first one is 0
Set olF = olNS.Folders.Item(0)
lrow = 1
For Each olM In olF.Items
With Sheets(Sheet3)
.Cells(lrow, 1) = olM.SenderName
.Cells(lrow, 2) = olM.Subject
.Cells(lrow, 3) = olM.Body
lrow = lrow + 1
End With
Next
Set olM = Nothing
Set olF = Nothing
Set olNS = Nothing
Set olA = Nothing
End Sub