Created
January 18, 2019 01:50
-
-
Save akilab/529c6954ddbc6024a0e8e2a381126e83 to your computer and use it in GitHub Desktop.
PythonでOutlookの指定したアカウントの下に下書きを作る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import sys | |
import win32com.client | |
import pythoncom | |
_VERSION_ = 'v0.1.0' | |
def show_version(): | |
print("=" * 20) | |
print("Draft Creater VERSION {}".format(_VERSION_).center(20)) | |
print("=" * 20) | |
def main(): | |
show_version() | |
pythoncom.CoInitialize() | |
outlook = win32com.client.Dispatch("Outlook.Application") | |
mapi = outlook.GetNamespace("MAPI") | |
# draft_box = mapi.GetDefaultFolder(16) # 16が下書きフォルダの番号らしい | |
draft_box = mapi.Folders("xxxx@xxxx.xxxx").Folders("下書き") | |
mail = outlook.CreateItem(0) | |
mail.To = 'to@example.com' | |
mail.Subject = '[Subject]' | |
mail.HtmlBody = '[HTML]' | |
mail.Move(draft_box) | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment