![]() You could use GetLast() or Sort() with appropriate message property to filter on the newest sent report. You could instead use string-method startswith on the message subject like (subject_prefix)Īnd call your method with a common prefix like save_attachments('PB Report - ').įurthermore use the attachment.FileName to construct the output-file path. The wildcard for parameter subject wont work because parameter subject is used as string when comparing for equality in message.Subject = subject. If 'PB' in message.subject and 'Report' in message.subject: I also have the alternative code but when i run this code i never get the result nor error. Outlook = ("Outlook.Application").GetNamespace("MAPI")Īttachment.SaveAsFile(os.path.join(path, str(attachment))) Path = r"C:/Users/greencolor/Desktop/Autoreport/" I tried wildcard(*) as save_attachments('PB Report*') but did not work. Also, how do I tell python to search the subject which starts with PB Report and dont look at the rest of the title. I would like to implement the GetLast in this code in order to get only the newest sent report. For example I received email this Monday with subject PB Report -, last week PB Report - and so on. Constant part of the subject title is PB Report and will have the Monday's date. Every Monday I receive the attachments with the slightly changed subject title.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |