I am trying to save attachments from outlook using the win32com package.
Is the error I am getting below somehow related to the policy for outlook? I do know when we go to save attachments in outlook there is a prompt asking if you are sure you would like to save. Is there a way I can force the saving of the attachment?
Code:
outputDir = r"C:\Path\to\directory"
try:
for message in list(messages):
try:
s = message.sender
for attachment in message.Attachments:
attachment.SaveASFile(os.path.join(outputDir, attachment.FileName))
print(f"attachment {attachment.FileName} from {s} saved")
except Exception as e:
print("error when saving the attachment:" + str(e))
except Exception as e:
print("error when processing emails messages:" + str(e))
Error:
error when saving the attachment:(-2147467260, 'Operation aborted', None, None)