I have 2 inbox in my outlook , I have created a macro to search mail from inbox ,but the issue is it is selecting the defaultfolder has first mailbox , have no idea how it would select second folder .
Thanks for the help in advance.
I have 2 inbox in my outlook , I have created a macro to search mail from inbox ,but the issue is it is selecting the defaultfolder has first mailbox , have no idea how it would select second folder .
Thanks for the help in advance.
You can select which Outlook-account to look through using something like this:
Outlook.Session.Accounts.Item(1) 'Change 1 to 2 for your alternate account
See Ron de Bruin's website for an example.
If you have two inboxes, than this will not help you. See the other answer posted by CoRrRan if this is the case. However from your question it sounds like you are trying to have it search a different folder other than your default mailbox. To return a different folder use the following.
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders("Folder Name")
Where you simply change "Folder Name" to whatever yours is called. You can then set your items equal to the myNewFolder.Items.