Gowrisankar Posted March 22, 2017 Posted March 22, 2017 Dear members of the forum, I'm new to AutoIt and I'm having a good time exploring and enjoying the features of AutoIt. For one of my tasks, I've to open few particular mails from outlook based on subject of the mails and then print the mails. Can someone please guide me how to do it? My question could be very silly for experts. But I'm just a beginner. Kindly advice. Thanks and regards, Gowrisankar R.
water Posted March 22, 2017 Posted March 22, 2017 Welcome to AutoIt and the forum! You could use _OL_ItemFind to search for the mails based on Subject and then loop throught he resulting array and call _OL_ItemPrint for each item. For each of this functions there is an example script in the OutlookEX ZIP file. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted March 22, 2017 Author Posted March 22, 2017 Thanks for the quick response Water. I'll try it out and get back...
Gowrisankar Posted March 27, 2017 Author Posted March 27, 2017 Hi water, I tried the below code but I'm getting the error as @error = 2 #include <OutlookEX.au3> Global $oOutlook = _OL_Open() Global $aItems = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "", "Subject", "Daily Process Report", "Subject", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Emails with expected string in Subject") MsgBox(0, "Information", UBound($aItems)) If $aItems[0][0] = 0 Then MsgBox(16, "OutlookEX UDF: _OL_ItemPrint Example Script", "Could not find a mail item with expected Subject") Else For $i = 1 To UBound($aItems) - 1 Step 1 _OL_ItemPrint($oOutlook, $aItems[$i][0]) Next If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemPrint Example Script", "Error printing specified note. @error = " & @error) MsgBox(64, "OutlookEX UDF: _OL_ItemPrint Example Script", "Note successfully printed") EndIf Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf I've attached the code and error snapshot as well. Please guide. SAMPLE.au3
water Posted March 27, 2017 Posted March 27, 2017 That's because you pass the Subject as parameter to _OL_ItemPrint. Use the EntryID instead: Global $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "", "Subject", "Menorca", "EntryID,Subject", "", 1) Gowrisankar 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted March 27, 2017 Author Posted March 27, 2017 Great water.. is there a way to open the mail before printing, so that I can choose the printer and then print?
water Posted March 27, 2017 Posted March 27, 2017 $oOL.Session.GetItemFromID($aItems[$i][0]).Display() should display the item. But selecting the printer and printing only works when you do it from the displayed item. Using _OL_Itemprint always uses the default printer. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted March 27, 2017 Posted March 27, 2017 Glad you like the solution My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted April 3, 2017 Author Posted April 3, 2017 @water Is there a way to print secure mails? Using the below code I was able to open secure mails. But when I sent print command through "Send("^p")", it doesn't work. $oOL.Session.GetItemFromID($aItems[$i][0]).Display()
water Posted April 3, 2017 Posted April 3, 2017 Did you try _OL_Itemprint? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted April 3, 2017 Author Posted April 3, 2017 Yes.. I get the following error. "Error printing specified note. @error = 3"
water Posted April 3, 2017 Posted April 3, 2017 And the value of @extended is? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted April 3, 2017 Author Posted April 3, 2017 @extended value is "-2147352567". Secure mail is of 4 types as per my understanding. I created 4 types of mails and tried the code for all the types. Of those 4 types, "Do not reply all" and "Do not edit" are working fine. "Do not forward" and "view only" are not working.
water Posted April 3, 2017 Posted April 3, 2017 (edited) Never worked with "secure mails" before. Can you manually print this mails? Edited April 3, 2017 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted April 3, 2017 Author Posted April 3, 2017 No water.. the print option is disabled when I check manually. Just now I noticed..
water Posted April 3, 2017 Posted April 3, 2017 So it seems to be a security feature - means: WAD (works as designed) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Gowrisankar Posted April 3, 2017 Author Posted April 3, 2017 Ha ha.. yes water.. So this feature can't be automated...
water Posted April 3, 2017 Posted April 3, 2017 Correct. What Outlook doesn't allow to do manually istn't allowed to be automated. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now