0

I have 2 mailboxes ([email protected] and [email protected]) in outlook and need to connect to a specific mailbox. By default, Python's win32com.client is connecting to the wrong one.

Is there a parameter to specify which mailbox to connect to? My code is:

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) messages = inbox.Items

I have tried very hard to find which parameters allow me to connect to a specific mailbox but did not see anything. Thanks for your help.

3
  • 1
    Can you see what for folder in outlook.Folders: print(folder.Name) gives you? Commented Apr 26, 2017 at 21:43
  • Thanks! It works. For some reason I was assuming that "folders" would be for folders like Inbox, Sent, etc and that there would be something like outlook.Mailbox for mailboxes. Did not know that they are all considered folders. Commented Apr 28, 2017 at 1:52
  • Glad it works for you! I posted my comment as an answer. Commented Apr 28, 2017 at 4:20

1 Answer 1

2

You should be able to enumerate the mailboxes with:

for folder in outlook.Folders: 
    print(folder.Name)
Sign up to request clarification or add additional context in comments.

Comments

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.