I have working code for advanced search of default Outlook inbox and sent items.
It is not working in shared mailboxes.
<code>Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
</code>
<code>Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
</code>
Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
Set recipient = Outlooknamespace.CreateRecipient(ThisWorkbook.Sheets("Macro").Range("e7").Value)
recipient.Resolve
Set Inboxfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Inbox")
Set Sentfolder = olApp.Session.GetSharedDefaultFolder(recipient, olFolderInbox).Parent.Folders("Sent Items")
' Get the Sent Items folder
subjectToSearch = "urn:schemas:httpmail:subject" & " LIKE '%" & subjectToSearch & "%' AND NOT " & "urn:schemas:httpmail:subject" & " LIKE '%Automatic Reply%'"
olSentIBFolder = "'" & Inboxfolder.FolderPath & "','" & Sentfolder.FolderPath & "'"
'Set outlookSearch = olApp.AdvancedSearch(olsentIBFolder, subjectToSearch)
1