Get Outlook Folder by Name with Python

Get Outlook Folder By Name With Python

Learn how to find an Outlook folder by name with Python.

Automating business tasks in Microsoft Outlook can save you tons of time. Python is a great tool that can help you automate Outlook tasks, such as finding a monthly email report a coworker regularly sends.

Many users find it helpful to file Outlook emails in folders outside of their inbox. The code below will help you access these custom folders by name.

You can easily do this with the win32com.client package. You will need to iterate through Outlook Folders using a for loop in Python. The function below allows you to input a specific folder name you want to use further in your script. It then iterates through each Outlook folder and checks if the folder name matches the folder name you want to find. If there is a match, it will return the folder as an object.

First, import the win32com.client and os packages.

Python Code

 
import win32com.client
import os

#having issues installing win32com? try the below (without the hashtag)
#pip install pypiwin32
#pip install pywin32
#python -m pip install pypiwin32
 

Full code below:

Python Code

 
import win32com.client
import os

#uses win32com to access Outlook
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
 
#loops through all Outlook folders to find given folder_name
def get_folder_by_name(folder_name):

    for folder in outlook.Folders.Item(1).Folders: 

        if folder.Name == folder_name:

            print ('Awesome, ' + folder_name + ' was found!')

            found_folder = folder

    return found_folder

 
#run functions

folder_name = 'Monthly Reports' #name of the Outlook folder you need

folder_needed = find_folder(folder_name)

print(folder_needed.Name)
 


Comments

63 responses to “Get Outlook Folder By Name With Python”

  1. Thanks for your write-up. My partner and i have always noticed that a majority of people are desperate to lose weight as they wish to look slim and also attractive. Nevertheless, they do not constantly realize that there are other benefits for losing weight in addition. Doctors claim that obese people experience a variety of conditions that can be directly attributed to their own excess weight. Fortunately that people that are overweight in addition to suffering from several diseases can help to eliminate the severity of the illnesses through losing weight. It’s possible to see a gradual but noted improvement with health if even a moderate amount of weight reduction is reached.

  2. Thanks for your help and for writing this post. It’s been great.

  3. May I request that you elaborate on that? Your posts have been extremely helpful to me. Thank you!

  4. Good web site! I truly love how it is easy on my eyes and the data are well written. I am wondering how I could be notified whenever a new post has been made. I’ve subscribed to your RSS which must do the trick! Have a nice day!

  5. Hello! I simply would like to offer you a huge thumbs up for the great information you have right here on this post. I will be coming back to your blog for more soon.

  6. I want to thank you for your assistance and this post. It’s been great.

  7. You helped me a lot by posting this article and I love what I’m learning.

  8. I’m so in love with this. You did a great job!!

  9. Woah! I’m really enjoying the template/theme of this site. It’s simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between superb usability and visual appeal. I must say you have done a great job with this. Also, the blog loads very quick for me on Chrome. Exceptional Blog!

  10. Thank you for providing me with these article examples. May I ask you a question?

  11. Good day very cool blog!! Man .. Excellent .. Superb .. I’ll bookmark your website and take the feeds I’m happy to search out so many helpful info here in the post, we’d like develop more techniques on this regard, thanks for sharing. . . . . .

  12. I enjoy what you guys are up too. This kind of clever work
    and reporting! Keep up the awesome works guys I’ve incorporated
    you guys to our blogroll.

  13. weekend pill tadalafil cialis generic ay cialis cause dizziness

  14. Howdy would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot faster then most. Can you recommend a good hosting provider at a fair price? Kudos, I appreciate it!

  15. cialis safe dose cialis tadalafil forum

  16. tadalafil india online linktr tadalafil 10mg generic cialis work

  17. cheapest cialis daily tadalafil tablets effects recommended cialis dosage

  18. cialis nitroglycerin interaction buy cialis generic cialis pills heallthllines

  19. tadalafil farmacias guadalajara original brand cialis tadalafil vs finasteride

  20. viagra tablet cost viagra boots england viagra price history

  21. tadalafil for memory cialis otc australia cialis forum erfahrungen

  22. tadalafil 20mg sale tadalafil effetti collaterali tadalafil price openair

  23. viagra subscribe newsletter viagra singapore forum viagra wiki eng

  24. viagra learning tool viagra connect kuwait viagra scheduled

  25. india viagra alternative viagra otc alternative sildenafil viagra cost

  26. cialis dosagem cialis dosing options tadalafil bnf dose

  27. cialis generico farmacia buying tadalafil online cialis 100mg online

  28. sildenafil in usa viagra takealot sildenafil prescribing guidelines

  29. ciga cialis medication tadalafil und grapefruitsaft cialis schedule

  30. viagra clicks viagra questionnaire boots sildenafil citrate class

  31. viagra alternative otc viagra connect walgreens viagra teeth hurt

  32. viagra competitor crossword viagra deals sildenafil heart disease

  33. sildenafil pronunciation key sildenafil vs kamagra viagra benefits health

  34. max dose viagra story of viagra viagra price history

  35. viagra erectile dysfunction viagra dose strength sildenafil dosage guide

  36. levitra ndc number least expensive levitra levitra adverse reactions

  37. sildenafil wirkstoff viagra pills name sildenafil citrate caverta

  38. levitra dosage options compare staxyn levitra levitra vs tadalafil

  39. enhance viagra effects sildenafil citrate viastoreus female viagra types

  40. levitra official levitra doses levitra vademecum

  41. sildenafil citrate pdf foods containing sildenafil teva sildenafil

  42. viagra flashback sildenafil dosage recommendations australia viagra prescription

  43. viagra australia coles viagra patent expires viagra deals

  44. different cialis strengths tadalafil pulm htn cialis max dose

  45. vardenafil 20mg cheap viagra versus levitra levitra reviews forum

  46. cialis dosage sizes cialis oder sildenafil tadalafil 40mg online

  47. viagra prices usa viagra bestellen veilig viagra liver disease

  48. viagra side viagra nombre quimico sildenafil citrate canada

  49. viagra switch plates viagra pill png viagra nhs price

  50. women and viagra taking viagra connect viagra song youtube

  51. levitra pkv dangers du levitra levitra paypal kaufen

  52. viagra generic cost sildenafil dosis perro viagra masculino preço

  53. tadalafil aurovitas opinie liquid tadalafil peptides prescription cialis cost

  54. viagra young male viagra generic doses viagra generic name

  55. One thing I would really like to discuss is that weightloss system fast may be accomplished by the proper diet and exercise. People’s size not only affects the look, but also the complete quality of life. Self-esteem, major depression, health risks, and physical ability are impacted in extra weight. It is possible to just make everything right whilst still having a gain. If this happens, a problem may be the reason. While too much food but not enough exercise are usually accountable, common health conditions and widespread prescriptions may greatly amplify size. Thanks for your post here.

  56. Sharing is caring the say, and you’ve done a fantastic job in sharing your knowledge on your blog. It would be great if you check out my page, too, at Webemail24 about Poisoning.

  57. Having read your blog, you obviously know what you are talking about. I’m sure visiting my page QN6 about Thai-Massage will be worth your time!

  58. It抯 onerous to seek out educated folks on this matter, but you sound like you already know what you抮e talking about! Thanks

  59. Hello! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about setting up my own but I’m not sure where to begin. Do you have any points or suggestions? Thank you

  60. One other issue issue is that video games usually are serious as the name indicated with the key focus on knowing things rather than fun. Although, it has an entertainment feature to keep your kids engaged, every single game is often designed to work with a specific experience or program, such as math concepts or scientific discipline. Thanks for your post.

Leave a Reply

Your email address will not be published. Required fields are marked *