Reputation: 11345
I have a shared inbox in outlook and I want to write some code that would get me the emails from the shared inbox. Right now I can get the emails from my main inbox, but I want to do it for another inbox.
This is the code so far:
import os
import win32com.client
outlook = win32com.client.Dispatch('Outlook.Application').GetNamespace('MAPI')
inbox = outlook.GetDefaultFolder(6).Folders('Some Magic Folder')
messages = inbox.Items
My guess is that I shouldn't be looking at the GetDefaultFolder method but something else, but I'm not quite sure where to look at.
Upvotes: 0
Views: 3968
Reputation: 49453
The GetSharedDefaultFolder method of the Namespace class returns a Folder object that represents the specified default folder for the specified user.
Sub ResolveName()
Dim myNamespace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim CalendarFolder As Outlook.Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev")
myRecipient.Resolve
If myRecipient.Resolved Then
Call ShowCalendar(myNamespace, myRecipient)
End If
End Sub
Sub ShowCalendar(myNamespace, myRecipient)
Dim CalendarFolder As Outlook.Folder
Set CalendarFolder = _
myNamespace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
CalendarFolder.Display
End Sub
Upvotes: 1