GithubHelp home page GithubHelp logo

Comments (4)

ecederstrand avatar ecederstrand commented on September 26, 2024

Getting to the folder named 'Undeliverable' is a little bit clunky. You need to do this:

my_folder = None
for k, v in account.folders.items():
    for f in v:
        if f.name == 'Undeliverable':
            my_folder = f
            break
    if my_folder:
        break

assert my_folder

If you already know the folder class of your folder, e.g. Messages, you can shorten this to:

for f in account.folders[Messages]:
    if f.name == 'Undeliverable':
        my_folder = f
        break
else:
    raise Exception('Folder not found')

There should probably be an easier way to do this.

from exchangelib.

ecederstrand avatar ecederstrand commented on September 26, 2024

I just committed a change so you can do:

my_folder = account.root.get_folder_by_name('Undeliverable')

Change root to another folder if 'Undeliverable' is not located under root.

from exchangelib.

MartinThoma avatar MartinThoma commented on September 26, 2024

for f in account.folders[Messages]:

It would be nice to add

 from exchangelib.folders import Messages

(Related to https://stackoverflow.com/q/45935701/562769 )

from exchangelib.

ecederstrand avatar ecederstrand commented on September 26, 2024

I've thought about this before, but then it would only make sense to import all the other folders types, and that would pollute the top-level import quite a bit. So for this atypical use case I think it's ok to do from exchangelib.folders import Message.

Anyway, the account.folders dict feels like a hack. I'd prefer to find a better solution to accessing the folder structure in #110

from exchangelib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.