├── .gitignore ├── README.md ├── YouTube ├── Q&A │ ├── cms_alerts.png │ ├── coach_summary.png │ └── upward_feedback.png ├── README.md ├── attachments.py ├── deal_filter.py ├── email_templates.py ├── format_image_html_template.py ├── happy_birthday.py ├── heatmap.xlsx ├── html_formatted.py └── py_mail_finder.py ├── birthday-cake.jpg ├── certificate.jfif ├── outlook-python-logo.png └── people.csv /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Outlook-Python-Tutorial 2 | Welcome to a series of tutorials on how to get the most out of Microsoft Outlook using python! 3 | **See the [WIKI for documentation](https://github.com/israel-dryer/Outlook-Python-Tutorial/wiki)** 4 | -------------------------------------------------------------------------------- /YouTube/Q&A/cms_alerts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/YouTube/Q&A/cms_alerts.png -------------------------------------------------------------------------------- /YouTube/Q&A/coach_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/YouTube/Q&A/coach_summary.png -------------------------------------------------------------------------------- /YouTube/Q&A/upward_feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/YouTube/Q&A/upward_feedback.png -------------------------------------------------------------------------------- /YouTube/README.md: -------------------------------------------------------------------------------- 1 |

2 |

The files included in this folder are supplementary code snippets for the YouTube video tutorials.

3 |

They are not meant to be used on their own.

4 | -------------------------------------------------------------------------------- /YouTube/attachments.py: -------------------------------------------------------------------------------- 1 | """ 2 | COPY AND PASTE CODE FOR YOUTUBE TUTORIAL 3 | 4 | Video Title: Python Outlook Email - Attachments - Learn how to control Microsoft Outlook using Python 5 | Video URL: https://youtu.be/omDnG4vO6Wc 6 | Last Modified: 7/30/2020 7 | """ 8 | 9 | html_body = """ 10 |
11 |

Happy Birthday!!

12 | Wishing you all the best on your birthday!! 13 |

14 |
15 | 16 |
17 | """ 18 | 19 | # code for changing the content id of the image 20 | image.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "cake-img") 21 | -------------------------------------------------------------------------------- /YouTube/deal_filter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Script that moves all files in a folder that contain the word 'deal' 3 | to a 'review' folder 4 | """ 5 | 6 | import win32com.client as client 7 | 8 | outlook = client.Dispatch('Outlook.Application') 9 | 10 | namespace = outlook.GetNameSpace('MAPI') 11 | 12 | folder = namespace.PickFolder() 13 | 14 | folderpath = folder.FolderPath 15 | account = folderpath[2:].split('\\')[0] 16 | account_folder = namespace.Folders[account] 17 | 18 | if 'JunkStuff' not in account_folder.Folders: 19 | junk = account_folder.Folders.Add('JunkStuff') 20 | else: 21 | junk = account_folder.Folders['JunkStuff'] 22 | 23 | to_move = [mail_item for mail_item in folder.Items 24 | if 'deal' in mail_item.Body.lower()] 25 | 26 | if to_move: 27 | for item in to_move: 28 | item.Move(junk) -------------------------------------------------------------------------------- /YouTube/email_templates.py: -------------------------------------------------------------------------------- 1 | """ 2 | COPY AND PASTE CODE FOR YOUTUBE TUTORIAL 3 | 4 | Video Title: Python Outlook Email - Email Templates - Learn how to control Microsoft Outlook using Python 5 | Video URL: 6 | Last Modified: 7/30/2020 7 | """ 8 | 9 | html_body = """ 10 |
11 |

12 | Happy Birthday!! 13 |

14 | 15 | {}, wishing you all the best on your birthday!! 16 | 17 |

18 |
19 | 20 |
21 | """ 22 | -------------------------------------------------------------------------------- /YouTube/format_image_html_template.py: -------------------------------------------------------------------------------- 1 | template = r""" 2 |

Happy Birthday!!

3 |

Wishing you all the best you your birthday!

4 | {IMAGE} 5 |

From your friends and co-workers

""" 6 | -------------------------------------------------------------------------------- /YouTube/happy_birthday.py: -------------------------------------------------------------------------------- 1 | import win32com.client as client 2 | 3 | html_body = """ 4 |
5 |

6 | Happy Birthday!! 7 |

8 | 9 | Wishing you all the best on your birthday!! 10 | 11 |

12 |
13 | 14 |
15 | """ 16 | 17 | def create_email(): 18 | """Create a happy birthday email and display it to the screen""" 19 | outlook = client.Dispatch('Outlook.Application') 20 | message = outlook.CreateItem(0) 21 | message.Subject = 'HAPPY BIRTHDAY!!' 22 | message.HTMLBody = html_body 23 | message.Display() 24 | 25 | if __name__ == '__main__': 26 | create_email() 27 | 28 | -------------------------------------------------------------------------------- /YouTube/heatmap.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/YouTube/heatmap.xlsx -------------------------------------------------------------------------------- /YouTube/html_formatted.py: -------------------------------------------------------------------------------- 1 | """ 2 | COPY AND PASTE CODE FOR YOUTUBE TUTORIAL 3 | 4 | Video Title: Python Outlook Email - HTML Formatted Email - Learn how to control Microsoft Outlook using Pythonhttps 5 | Video URL: https://youtu.be/GQkXs-ncS4g 6 | Last Modified: 7/30/2020 7 | """ 8 | 9 | html_body = """ 10 |
11 |

12 | Happy Birthday!! 13 |

14 | 15 | Wishing you all the best on your birthday!! 16 | 17 |

18 |
19 | 20 |
21 | """ 22 | -------------------------------------------------------------------------------- /YouTube/py_mail_finder.py: -------------------------------------------------------------------------------- 1 | """ 2 | Script that looks for all mail in my inbox with a subject that contains 3 | the words 'Python' and save the recient and subject line in a csv file 4 | """ 5 | 6 | import csv 7 | from datetime import datetime 8 | import win32com.client as client 9 | 10 | def mail_body_search(term, folder): 11 | """Recursively search all folders for email containing the search term""" 12 | try: 13 | relevant_messages = [message for message in folder.Items if term in message.Body.lower()] 14 | except AttributeError: 15 | # not items in the current folder 16 | relevant_messages = [] 17 | 18 | # check for subfolders (base case) 19 | subfolder_count = folder.Folders.Count 20 | 21 | # search all subfolders 22 | if subfolder_count > 0: 23 | for subfolder in folder.Folders: 24 | relevant_messages.extend(mail_body_search(term, subfolder)) 25 | 26 | return relevant_messages 27 | 28 | # extract all python messages and save select data to file 29 | today = datetime.today().strftime('%Y%m%d') 30 | outlook = client.Dispatch('Outlook.Application') 31 | namespace = outlook.GetNameSpace('MAPI') 32 | messages = mail_body_search('python', namespace) 33 | 34 | with open('py_mail_' + today + '.csv', 'w', newline='', encoding='utf-8') as f: 35 | writer = csv.writer(f) 36 | for item in messages: 37 | sender_email = item.SenderEmailAddress 38 | subject = item.subject 39 | writer.writerow([sender_email, subject]) 40 | -------------------------------------------------------------------------------- /birthday-cake.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/birthday-cake.jpg -------------------------------------------------------------------------------- /certificate.jfif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/certificate.jfif -------------------------------------------------------------------------------- /outlook-python-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israel-dryer/Outlook-Python-Tutorial/89cb3eb78c9386137c1fbaa5a4c0e49823e5782c/outlook-python-logo.png -------------------------------------------------------------------------------- /people.csv: -------------------------------------------------------------------------------- 1 | Louis Agnello,testing@outlook.com 2 | Brendan Dunn,testing@outlook.com 3 | Christina Haley,testing@outlook.com 4 | Virgil Miller,testing@outlook.com 5 | Ed Pagano,testing@outlook.com 6 | Zach Rudisill,testing@outlook.com 7 | Arshi Siddiqui,testing@outlook.com 8 | Elinor Hiller,testing@outlook.com 9 | Michael Park,testing@outlook.com 10 | Earl Pomeroy,testing@outlook.com 11 | Bob Siggins,testing@outlook.com 12 | Timothy P Trysla,testing@outlook.com 13 | Alexandra Minkovich,testing@outlook.com 14 | Joshua Odintz,testing@outlook.com 15 | Tiffani Williams,testing@outlook.com 16 | David Bockorny,testing@outlook.com 17 | Blair Larkins,testing@outlook.com 18 | Gavin Proffitt,testing@outlook.com 19 | Joseph Rubin,testing@outlook.com 20 | Scott B Styles,testing@outlook.com 21 | David Jory,testing@outlook.com 22 | Brian Sutter,testing@outlook.com 23 | Thomas Wharton,testing@outlook.com 24 | Emily Wilkinson,testing@outlook.com 25 | Elizabeth Brooks,testing@outlook.com 26 | Glen Chambers,testing@outlook.com 27 | Rosalyn Kumar,testing@outlook.com 28 | Joy A McGlaun,testing@outlook.com 29 | Shannon Penberthy,testing@outlook.com 30 | Amy Rosenbaum,testing@outlook.com 31 | Sarah Schmidt,testing@outlook.com 32 | Melissa Schulman,testing@outlook.com 33 | Oscar T Ramirez,testing@outlook.com 34 | Dana J Thompson,testing@outlook.com 35 | Aaron Trujillo,testing@outlook.com 36 | Lori Denham,testing@outlook.com 37 | Adam Hechavarria,testing@outlook.com 38 | MJ Kenny,testing@outlook.com 39 | Lisa Kountoupes,testing@outlook.com 40 | Randi Reid,testing@outlook.com 41 | Maura Keefe,testing@outlook.com 42 | Brian Greer,testing@outlook.com 43 | Matthew Johnson,testing@outlook.com 44 | Izzy Klein,testing@outlook.com 45 | Katie Weider,testing@outlook.com 46 | Rodney Whitlock,testing@outlook.com 47 | Leonard Jr Bickwit,testing@outlook.com 48 | Marc J Gerson,testing@outlook.com 49 | --------------------------------------------------------------------------------