pax Posted November 28, 2012 Share Posted November 28, 2012 Really bad news But at least you tried it. thank you very much for your effort! Link to comment Share on other sites More sharing options...
water Posted November 28, 2012 Author Share Posted November 28, 2012 What would you do with the information that the PST is password protected? As you can't enter the password by your script the user always has to enter it himself. 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 Link to comment Share on other sites More sharing options...
Mun Posted December 8, 2012 Share Posted December 8, 2012 Water, Thank you for creating this UDF. How would one go about checking new mail if there any attachment and save it to a folder? Crayfish 1 Link to comment Share on other sites More sharing options...
water Posted December 8, 2012 Author Share Posted December 8, 2012 The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console. Use _OL_ItemAttachmentSave to save the attachments of your mails. #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <OutlookEX.au3> Global $aAttachments ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; Access the Inbox Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended) ; Search for unread items with attachments Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0" Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject") If @error Then MsgBox(16, "OutlookEX UDF - _OL_ItemSearch Example Script", "Error running _OL_ItemSearch. @error = " & @error & ", @extended = " & @extended) Else _Arraydisplay($aResult, "Example 6") EndIf ; Now get a list of attachments For $i = 1 To $aResult[0][0] ConsoleWrite($aResult[$i][1] & @CRLF) ; Mail subject $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0]) For $j = 1 To $aAttachments[0][0] ConsoleWrite(" " & $aAttachments[$j][2] & @CRLF) ; Name of atachment Next Next _OL_Close($oOutlook) Exit Mun and Crayfish 2 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 Link to comment Share on other sites More sharing options...
HighlanderSword Posted December 8, 2012 Share Posted December 8, 2012 (edited) Water, Do you have any Plans to add option to allow us to compact a PST file ? I've created a Autoit process using your UDF that moves items around, deletes them etc. I have found that Outlook does not seem to compact on a reliable basis , for example aftter moving 4000 items to the deleted folder and purging them, and waited 5 days , the Outlook Compact never ran. I ran it manually on the 5th day and it took the size of the PST folder from 2.9 Gig, down to 200 MB. Please let me know if this is something you are considering ? Thanks Paul Edited December 8, 2012 by HighlanderSword Link to comment Share on other sites More sharing options...
water Posted December 8, 2012 Author Share Posted December 8, 2012 I have considered to add a PST compact function. Unfortunately Outlook doesn't offer a method in the object model. So, no, there will be no such function in the OutlookEX UDF. The only way to do it by script is to automate the Outlook GUI. Crayfish 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 Link to comment Share on other sites More sharing options...
Mun Posted December 8, 2012 Share Posted December 8, 2012 Thank you Water - You make it seem so easy. I have a question. Is it possible not to include people big signature in my attachment? and I only want it to save the pdf file not all the jpg gif that come with the email? The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console. Use _OL_ItemAttachmentSave to save the attachments of your mails. #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <OutlookEX.au3> Global $aAttachments ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; Access the Inbox Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended) ; Search for unread items with attachments Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0" Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject") If @error Then MsgBox(16, "OutlookEX UDF - _OL_ItemSearch Example Script", "Error running _OL_ItemSearch. @error = " & @error & ", @extended = " & @extended) Else _Arraydisplay($aResult, "Example 6") EndIf ; Now get a list of attachments For $i = 1 To $aResult[0][0] ConsoleWrite($aResult[$i][1] & @CRLF) ; Mail subject $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0]) For $j = 1 To $aAttachments[0][0] ConsoleWrite(" " & $aAttachments[$j][2] & @CRLF) ; Name of atachment Next Next _OL_Close($oOutlook) Exit Crayfish 1 Link to comment Share on other sites More sharing options...
Crayfish Posted December 8, 2012 Share Posted December 8, 2012 Water, Thanks for the assist and I couldn't reply thanks to PM. Mine seems to be over complicated. #include <OutLookEX.au3> Global $aItems, $Result Global $oOutlook = _OL_Open() Global $oOApp = ObjCreate("Outlook.Application") Global $aFolder = _OL_FolderAccess($oOutlook, "*Inbox", Default, Default) Global $sFilter = "@SQL=(""urn:schemas:httpmail:hasattachment"" = 1 AND ""urn:schemas:httpmail:read"" = 0)" $aItems = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID") ;~ $aItems = _OL_ItemFind($oOutlook, $vOlFolder, $olMail, "[UnRead]=True", "", "", "EntryID", "") If IsArray($aItems) Then For $i = 1 To $aItems[0][0] $Result = _OL_ItemAttachmentGet($oOutlook, $aItems[$i][0], Default) ;mark as read first to prevent read receipt confusion massacre _OL_ItemModify($oOutlook, $aItems[$i][0], Default, "UnRead=False") Global $oOL_Item = $oOApp.Session.GetItemFromID($aItems[$i][0], Default) Global $var = $oOL_Item.Subject If IsArray($Result) Then For $r = 1 To $Result[0][0] _OL_ItemAttachmentSave($oOutlook, $aItems[$i][0], Default, 1, "c:outlook" & $var & "" & $Result[$r][1]) Next Else ;YAY! EndIf Next Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf Link to comment Share on other sites More sharing options...
water Posted December 8, 2012 Author Share Posted December 8, 2012 (edited) @Mun, use _OL_ItemAttachmentGet to get a list of all attachments of a mail item. You then can decide which one to save using _OL_ItemAttachmentSave.What do you mean by : "not to include people big signature in my attachment"? Edited December 8, 2012 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 Link to comment Share on other sites More sharing options...
water Posted December 8, 2012 Author Share Posted December 8, 2012 @Crayfish, Why do you use Global $oOApp = ObjCreate("Outlook.Application")That's exactly what is returned by _OL_Open. 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 Link to comment Share on other sites More sharing options...
Mun Posted December 8, 2012 Share Posted December 8, 2012 It saved people signature images as additional attachment. I will read up and on what you suggested thanks Water@Mun,use _OL_ItemAttachmentGet to get a list of all attachments of a mail item. You then can decide which one to save using _OL_ItemAttachmentSave.What do you mean by : "not to include people big signature in my attachment"? Crayfish 1 Link to comment Share on other sites More sharing options...
Mun Posted December 10, 2012 Share Posted December 10, 2012 Water, I read up on it. I still can't able to filter out those signature gif/jpg not to include in the folder. Is there a way? Could you check up on the following code to see if it's done correctly? #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y #include <OutlookEX.au3> #include <Array.au3> Global $aAttachments Global $oOutlook = _OL_Open() Global $SaveLOC = @ScriptDir & "\MSG_TEST\" ; Access the Inbox Global $aFolder = _OL_FolderAccess($oOutlook, "*\Inbox", $olFolderInbox) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended) ;Search for unread items with attachments Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0" Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,Subject") For $Email = 1 To $aResult[0][0] $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$Email][0]) ConsoleWrite($aResult[$Email][1] & " Attachments: " & $aAttachments[0][0] & @CRLF) For $AIndex = 1 To $aAttachments[0][0] _OL_ItemAttachmentSave($oOutlook, $aResult[$Email][0], Default, $AIndex, $SaveLOC & $aResult[$Email][1] & "\" & $aAttachments[$AIndex][2]) If @error <> 0 Then MsgBox(16, "Error", "Error saving attachments to folder. @error = " & @error & ", @extended = " & @extended) sleep(200) Next Next ; Close connection to Outlook _OL_Close($oOutlook) Link to comment Share on other sites More sharing options...
water Posted December 10, 2012 Author Share Posted December 10, 2012 If the signature of a user contains an attachment then it's an attachment like any other attachment to the recipient. The signature is a part of the message. If you can't distinguish by name, filetype or whatever then you are out of luck. 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 Link to comment Share on other sites More sharing options...
Mun Posted December 10, 2012 Share Posted December 10, 2012 Thanks Water. I will find a way to see if I can parse the body message. Link to comment Share on other sites More sharing options...
water Posted December 18, 2012 Author Share Posted December 18, 2012 As the OutlookEX UDF - Help & Support thread has grown too big, I started a new one.The new thread can be found 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 Link to comment Share on other sites More sharing options...
Recommended Posts