water Posted January 22, 2013 Author Share Posted January 22, 2013 Lets see if it works! Haven't tested it because I have no user forms. 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...
minimen456 Posted January 30, 2013 Share Posted January 30, 2013 Hi, water! Thank you for your great work. I’d like to ask a question about how to control Outlook. I need to do some clicking in the command menu (like: Tools-> Account Settings... -> Data Files - > Add... -> OK -> OK -> Close). Is it possible to do with your UDF? Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 The UDF doesn't automate the GUI (command menu etc.) but uses COM to interact with Outlook. Not everything in Outlook can be automated using the UDF because not every function is made available by Microsoft via COM. If you want to add a PST file use function _OL_PSTAccess. 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 Hello again. I have a quick Question. I have a script that dumps alot of mail to a PST (you helped me with it earlier. Thanx). Not the problem is that a problem with my storage solution made the program crash and the mailbox is now filled with over 500 000 mail. And the script is designed to use OL_ItemFind all mail in the inbox and move them to the PST. The problem is that the _OL_FindItem takes forever to go trough the 500 000 items. So the question is. Can you limit it to about 100? So when the array (returned by OL_ItemFind) only get to be 100 posts or 200 posts? That way ai can deal with some of the mail, little by little? I tried using restructions like this: "[subject] > 'au' And [subject] < 'az'" but i still get over 7000 posts. Any idees? Thank you. Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 Tjalve, Not by the number of items returned. But you could limit the search by date. All mails received in January etc. 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 Ive tried toing that but coulden get it to work. Can you help me design a query that only returns the items that was recived in the last hour? Im thinking like this: $listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "LAST HOUR", "", "", "EntryID") if $listofmail[0][0] = 0 then $listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "LAST 2 HOURS", "", "", "EntryID") if $listofmail[0][0] = 0 then $listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "LAST 3 HOURS", "", "", "EntryID") endif endif So that first i dump all the mails from the last hour, and then the ones from 2 hours ago, and then 3 and so on. It may not be pretty but i cant have a larges span becuase there will be WAY to many mail for th fuction to handle. Link to comment Share on other sites More sharing options...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 (edited) or pehaps you could use a while loop that increase the span for every run. Somthing like this perhaps? $run = 1 while 1 $listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "LAST $run HOURS", "", "", "EntryID") if $listofmail[0][0] = 0 then $run = $run + 1 else $run = 1 endif wend Edited January 30, 2013 by Tjalve Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 To get all mail items you received in January you would use the following script (Replace "Posteingang" with the name of your Inbox): #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[ReceivedTime]>'2013-01-01 00:00' And [ReceivedTime]<'2013-01-31 23:59'", "", "", "Subject,ReceivedTime") If IsArray($aItems) Then _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find any mail. @error = " & @error & ", @extended: " & @extended) EndIf _OL_Close($oOutlook) 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 Alright. So based on this: "[ReceivedTime]>'2013-01-01 00:00' And [ReceivedTime]<'2013-01-31 23:59'" Then this should oly take the mail from the last hour: "[ReceivedTime]>'" & @year & "-"& @mon & "-"& @mday & " " & @HOUR & ":00' And [ReceivedTime]<'" & @year & "-"& @mon & "-"& @mday & " " & @HOUR & ":59'" Right? Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 Correct. 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 Thanx a MILION Water. I created a small while loop inside my main loop. while 1 ConsoleWrite("Letar efter mail " & $hour + 1 & " timmar bakåt i tiden..." & @CRLF) $listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "[ReceivedTime]>'" & @year & "-"& @mon & "-"& @mday & " " & @HOUR +$hour & ":00' And [ReceivedTime]<'" & @year & "-"& @mon & "-"& @mday & " " & @HOUR & ":59'", "", "", "EntryID") if $listofmail[0][0] = 0 Then $hour = $hour + 1 Else $hour = 0 ExitLoop EndIf WEnd This code checks one hour back for new mail. If none is found, the search span increases to 2 hours, the 3 and so on. And It seems like its working great Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 (edited) You have to substract the hours not add. You can't have any mails that you received one or multiple hours in the future. You need something like this to calculate a correct date if you cross the date line (the example would list all items you received in the last 8 hours): #include <date.au3> $sNow = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":00:00" ConsoleWrite("Now is: " & $sNow & @LF) $sResult = _DateAdd("h", -8, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":00:00") ConsoleWrite("Now minus 8 hours is: " & $sResult & @LF) $sResult = StringReplace(StringLeft($sResult, 16), "/", "-") ConsoleWrite("New Date for _OL_ItemFind is: " & $sResult & @LF) Edited January 30, 2013 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 yeah i found that my example above did not work. Ive recreated my script now and it increases by the hour first, and then by the day and then by the mon. Thanks again. You rock Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 Glad to be of service 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...
Tjalve Posted January 30, 2013 Share Posted January 30, 2013 haha come to think of it. is there a way to "Empty the trash" in a simple way? Instead of using _ol_itemfind on all the items in the deleted folder, and then delete every mail seperatly? Link to comment Share on other sites More sharing options...
water Posted January 30, 2013 Author Share Posted January 30, 2013 Check the _OL_FolderDelete.au3 example script. Example 2 shows how to do. 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...
BadGrim Posted January 31, 2013 Share Posted January 31, 2013 Hello all, I have used this udf in the past to create a script that disconnects all the pst files. Now, i need to just check the 'folder size' for the current users mailbox as a whole, not just the inbox. The whole mailbox. We are currently doing away with pst files and increasing users mailboxes to one gig. I just want to create a script that will simply display the size of their mailbox, so they do not go over their limit while migrating pst data into their core mailbox. Thoughts, suggestions? Link to comment Share on other sites More sharing options...
water Posted January 31, 2013 Author Share Posted January 31, 2013 As far as I know there is now way to retrieve the folder size using COM. Only way I see at the moment is to open the PST in a separate window using the OutlookEX UDF and then automate this window using plane AutoIt. 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...
BadGrim Posted January 31, 2013 Share Posted January 31, 2013 As far as I know there is now way to retrieve the folder size using COM.Only way I see at the moment is to open the PST in a separate window using the OutlookEX UDF and then automate this window using plane AutoIt.Im not looking for the size on the local pst file. Im looking for the size of the exchange mailbox (of course, I guess that may be a pst as well). Link to comment Share on other sites More sharing options...
water Posted January 31, 2013 Author Share Posted January 31, 2013 Im not looking for the size on the local pst file. Im looking for the size of the exchange mailbox (of course, I guess that may be a pst as well).The current size of the mailbox can be taken from Outlook as described above. BTW: An exchange mailbox is never a PST.If you can retrieve the maximum allowed size (quota) depends on the Outlook, Exchange and Windows version you run. Can you please provide this information? 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