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
if you want to just save the attachment, comment out the last 3 lines and write the entire directory in last 4th line to save at a specific location.
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.
Where do you think the current working directory is? I'd say you are looking at the wrong folder, SaveAsFile
in general works just fine.
Simply pass a full path to SaveAsFile
, that should solve your problem.