How to save attachment from outlook using win32com.client in Python?

后端 未结 3 1123
北海茫月
北海茫月 2020-12-09 06:08

Im trying to read email and download the attachment to my own folder using win32com module in Python, I stopped at getting the attachment object:

from win32c         


        
3条回答
  •  萌比男神i
    2020-12-09 06:29

    Just to update, I have solved this issue by claiming both dir and the file name itself in SaveAsFile:

    att.SaveAsFile(os.getcwd() + '\\new.xlsx')
    

    It is not like most threads I've seen here saying that you only need to put path in it. Actually both path and file name are needed.

    Also, weirdly, you have to put os.getcwd() here since Python wouldn't recognize current running dir - in R, after we set working dir with getwd(), we are able to write to any file at this location.

提交回复
热议问题