Yes, it is possible. You can automate Outlook from python. See Automating Outlook using Python win32com to get started quickly.
Iterate through outlook folders and search by key word "Approved" or "Approve" or "approved" or "approve" in the email body.
There is no need to iterate through Outlook folders. Instead, you may consider using the AdvancedSearch
method of the Application
class.
The key benefits of using the AdvancedSearch
method in Outlook are:
- The search is performed in another thread. You don’t need to run another thread manually since the
AdvancedSearch
method runs it automatically in the background.
- Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The
Restrict
and Find
/FindNext
methods can be applied to a particular Items
collection (see the Items
property of the Folder
class in Outlook).
- Full support for DASL queries (custom properties can be used for searching too). You can read more about this in the Filtering article in MSDN. To improve the search performance,
Instant Search
keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled
property of the Store
class).
- You can stop the search process at any moment using the
Stop
method of the Search
class.
Read more about the AdvancedSearch
method in the Advanced search in Outlook programmatically: C#, VB.NET article.
You can use the Word editor to save the item using the PDF file format:
Word.Document doc = mailItem.GetInspector.WordEditor;
doc.SaveAs2(fullPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);
Also you may consider using the ExportAsFixedFormat method from the Word object model which saves a document as PDF or XPS format.
The Attachment.SaveAsFile method saves the attachment to the specified path.