I'm trying to automate saving emails in our folders from outlook. I don't see a code for saving an email as .msg or any other type.
import win32com.client
import os
os.chdir("filepathhere")
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts;
Tokyo = "email from Tokyo"
inbox = outlook.GetDefaultFolder(6)
subject = Tokyo
messages = inbox.Items
message = messages.GetFirst()
for msg in messages:
if msg.subject == Tokyo:
msgname = msg.subject
msgname=str(msgname)
print msgname
message.saveasfile(msgname+".msg")
I get the error message: AttributeError: .saveasfile