0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

3 Comments

inbox = outlook.GetSharedDefaultFolder(6) File "<COMObject GetNamespace>", line 3, in GetSharedDefaultFolder TypeError: The Python instance can not be converted to a COM object getting that error
Did you pass a valid recipient object to the GetSharedDefaultFolder method?
ah, I think I may know how to approach this. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.