Python と Windows 拡張機能を使用して Outlook から電子メールの添付ファイルをダウンロードしようとしていますが、これまでに次のことを試しました。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders('Subfolder')
messages = inbox.Items
message = messages.GetLast() #open last message
attachments = message.Attachments #assign attachments to attachment variable
attachment = attachments.Item(1)
attachment.SaveASFile("File_name")
このコードは、ファイルをファイル名 "File_name" で保存します。保存に使用しているファイル名として元のファイル名を使用する方法はありますか?