When I used win32com.client to send outlook emails with one than one attachments in Python, I want to add multiple attachments with twice "mail.Attachments.Add()" However, it will intermittently lead to an error that said "This file could not be found. Please verify that the path and file name are correct." How interesting is that sometimes it will run normally, and sometimes will have this error. But when I used "mail.Attachments.Add()" only once it never lead to this error.
I wonder why it is. If this way is not reliable, is there other way to add multiple attachments to send outlook emails.
I have made sure the path is existing.
def send_email(path, detail_path, datestr, name):
olook = win32.Dispatch("outlook.Application")
mail = olook.CreateItem(0)
mail.HTMLBody = body_html
mail.Subject = datestr + 'summary'
# summary
mail.Attachments.Add(path)
# detail
mail.Attachments.Add(detail_path)