Skip to content

Instantly share code, notes, and snippets.

@akilab
Created January 18, 2019 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akilab/529c6954ddbc6024a0e8e2a381126e83 to your computer and use it in GitHub Desktop.
Save akilab/529c6954ddbc6024a0e8e2a381126e83 to your computer and use it in GitHub Desktop.
PythonでOutlookの指定したアカウントの下に下書きを作る
# 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