We are using the following VB code snippet to successfully attach a script to unread emails in the user's default inbox. This works very well.
Dim oOlAp
Dim oOlns
Dim oOlInb
Dim oOlItm
Dim oOlAtch
Sub LocateEmail
Set objOLApp = CreateObject("Outlook.Application")
If objOLApp is nothing then
MsgBox "Could not connect with (Outlook) ... exiting"
Exit Sub
End If
Set oOlns = objOLApp.GetNamespace("MAPI")
Set oOlInb = oOlns.GetDefaultFolder(6)
If oOlInb.Items.Restrict("[UnRead] = True").Count = 0 Then
MsgBox "NO Unread Email In Inbox"
Exit Sub
End If
For Each oOlItm In oOlInb.Items.Restrict("[UnRead] = True")
MsgBox oOlItm.SenderEmailAddress
Next
Set objOLApp = Nothing
End Sub
However, we also now need to attach the script to other folders and inboxes listed in the user's Outlook. How would the code above differ to achieve this ?
VB Snippet For Multiple Outlook Folders
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 11
- Joined: Sat Oct 28, 2017 11:49 am
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: VB Snippet For Multiple Outlook Folders
This is a Microsoft VBScript question. I Googled it for you and found these likely helpful articles:
https://msdn.microsoft.com/en-us/vba/ou ... od-outlook
https://msdn.microsoft.com/en-us/vba/ou ... on-outlook
https://msdn.microsoft.com/en-us/vba/ou ... od-outlook
https://msdn.microsoft.com/en-us/vba/ou ... on-outlook
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?