Python win32com Outlook Stores not iterable

2024/11/17 23:35:22

Trying to list all Outllook stores (and finally all e-mails in those stores):

import win32com.clientoutlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
stores = outlook.Stores
print(stores.Count)
for store in outlook.Session.Stores:print(store.GetRootFolder())

While it was still working yesterday I see the following output today:

Traceback (most recent call last):
10File "C:/Users/DJ/PycharmProjects/Mailmagic/outlook_test.py", line 6, in <module>for store in outlook.Session.Stores:
TypeError: 'Stores' object is not iterableProcess finished with exit code 1

In between I was running makepy.py. Version: Microsoft Outlook 16.0 Object Library

Answer

Finally switching from stores to outlook.Folders worked for me. See below.

import win32com.clientoutlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
for folder in outlook.Folders:print(folder.Name)
https://en.xdnf.cn/q/118746.html

Related Q&A

Using a users input to search dictionary keys and print that keys matching value

I am working with tkinter, as I have my gui set up with and entry, label, and button. Im trying to search my dictionarys keys with the users input from the entry, and print the value of the key that wa…

How to write CSV into the next column

I have output that I can write into a CSV. However, because of how i setup my XML to text, the output iterates itself incorrectly. Ive tried a lot to fix my XML output, but I dont see any way to fix it…

Comparing date from pandas dataframe to current date

Im currently trying to write a script that does a specific action on a certain day. So for example, if today is the 6/30/2019 and in my dataframe there is a 6/30/2019 entry, xyz proceeds to happen. How…

How to divide a binary file to 6-byte blocks in C++ or Python with fast speed? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 5…

Selenium, python dynamic table

Im creating a robot with selenium that get all info from agencies in Brasil, ive alredy done the permutation click between all States and counties, all i have to do nows click in all agencies and get i…

How to split string into column

I got a csv file with some data, and I want to split this data.My column one contains a title, my column 2 contains some dates, and my column 3 contains some text linked to the dates.I want to tran…

remove whitespaces with new line characters

I have a string that looks like that:"\n My name is John\n and I like to go.\n blahblahblah.\n \n\n ".Note - In this string example, there are 5 white-spaces after…

Python tkinter GUI freezing/crashing

from Tkinter import * import tkFileDialog import tkMessageBox import os import ttkimport serial import timeit import time################################################################################…

If/else in python list comprehension

I would like to return random word from file, based on passed argument. But if the argument doesnt match anythning I dont want to return anything. My method looks like:def word_from_score(self,score):p…

Conditional module importing in Python

Im just trying out Maya 2017 and seen that theyve gone over to PySide2, which is great but all of my tools have import PySide or from PySide import ... in them.The obvious solution would be to find/rep…