tw12lve Posted September 7, 2012 Posted September 7, 2012 Hopefully you are still reading this thread. It seems your library is what I want to do the following: -Take 3 parameters from command line (after compiling autoit script to exe) [ toAddress, subject, dateSent ] -Look in Outlook's Sent Items folder for the matching message -If found, open message on screen -If not, return 1 to end the process I have a real Outlook environment I'm running this against but I'm not familiar with how it wants the folder formatted. I'm guessing from examples that you need to us _OL_FolderAccess to get the identifier for the "Sent Items" folder and then _OL_ItemFind to match the message. This is the code I've put together #include Global $oOutlook = _OL_Open() Global $aFolder = _OL_FolderAccess($oOutlook, "Outlook\Sent Items") Global $aItems = _OL_ItemFind($oOutlook, $aFolder, $olMail, "Subject=Re:&ToAddress=me@test.com&SentDate=2-4-12 3:02pm", "", "", "Subject,Body", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, "Matching Email") ; Open $aItems[0] Else MsgBox(48, "Error") return 1 EndIf I know this is wrong, but I don't understand how outlook stores it's files or what "Sent Items" really is. You don't seem to mention it at all in your library. Ideas?
water Posted September 7, 2012 Author Posted September 7, 2012 (edited) Welcome to AutoIt and the forum. You have a lot of errors in your script. Please read the help files that come with every function and the Wiki. Try the following code. It is untested and the function to convert the EntryID to the $object is mssing. Can't test because I don't have Outlook at home. #include <Outlook.au3> Global $oOutlook = _OL_Open() If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_Open. @error = " & @error & ", @extended = " & @extended) Global $aFolder = _OL_FolderAccess($oOutlook, "*Sent Items") If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_FolderAccess. @error = " & @error & ", @extended = " & @extended) Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "[Subject]='Re:' And [ToAddress]='me@test.com' And [SentDate]='2-4-12 3:02pm'", "", "", "EntryID,Subject,Body", "", 1) If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_ItemFind. @error = " & @error & ", @extended = " & @extended) If IsArray($aItems) Then _ArrayDisplay($aItems, "Matching Email") $object.Display Else MsgBox(48, "Error") return 1 EndIf Edited September 7, 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
bruudx Posted September 12, 2012 Posted September 12, 2012 Hi all,I'm trying to experiment with OutlookEX UDF. I'm trying to get a list of all the email items from a shared mailbox.The name of the shared mailbox is: ICT Servicedesk (firstname: Servicedesk, Lastname: ICT)I tried the following script:#include <OutlookEX.au3> Global $asUnreadmails[1], $asTemp, $iIndexFolder, $iIndexMail = 0, $iUnReadMails, $iIndexItem Global $oOutlook = _OL_Open() Global $asFolderList = _OL_FolderFind($oOutlook, "\\ICT Servicedesk\Inbox", 99, "", 1, $olMailItem) For $iIndexFolder = 1 To $asFolderList[0][0] $iUnReadMails = $asFolderList[$iIndexFolder][0] .Items.Count If $iUnReadMails > 0 Then ConsoleWrite($asFolderList[$iIndexFolder][0].Folderpath & " Number of unread mails: " & $asFolderList[$iIndexFolder][0].UnReadItemCount & @CRLF) ReDim $asUnreadmails[UBound($asUnreadmails) + $iUnReadMails] $asTemp = _OL_ItemFind($oOutlook, $asFolderList[$iIndexFolder][0], $olMail, "[UnRead]=True", "", "", "EntryID", "") For $iIndexItem = 1 To $asTemp[0][0] $iIndexMail += 1 $asUnreadmails[$iIndexMail] = $asTemp[$iIndexItem][0] Next EndIf NextThe script gives error:Subscript used with non-Array variable.: For $iIndexFolder = 1 To $asFolderList[0][0] For $iIndexFolder = 1 To $asFolderList^ ERRORWhen changing "\\ICT Servicedesk\Inbox" to "*" the script works fine. Got the script from a other topic. I think I'm doing something wrong with the shared mailbox.Can you guys help me?Thanks in advance!
water Posted September 12, 2012 Author Posted September 12, 2012 Whats the error code returned by _OL_FolderFind? Insert the following MsgBox: Global $asFolderList = _OL_FolderFind($oOutlook, "ICT ServicedeskInbox", 99, "", 1, $olMailItem) MsgBox(0, "Error", @error) 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
bruudx Posted September 12, 2012 Posted September 12, 2012 Looks like it gives error 2. 2 - Error accessing the specified folder. See @extended for errorcode returned by _OL_FolderAccess The extended error code is 1. I don't know what that means. Looks like the format is wrong. I tried all kind of formats for the email box, but can't get it to work. Any thoughts on this? Thank you!
water Posted September 12, 2012 Author Posted September 12, 2012 To access the folder of another user you should use something like this: Global $aFolder = _OL_FolderAccess($oOutlook, "\\ICT Servicedesk\Inbox", $olFolderInbox) if @error then MsgBox(0, "Error", "Error returned by _OL_FolderAccess: " & @error & "-" & @extended) Global $asFolderList = _OL_FolderFind($oOutlook, $aFolder[1], 99, "", 1, $olMailItem) if @error then MsgBox(0, "Error", "Error returned by _OL_FolderFind: " & @error & "-" & @extended) 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 September 12, 2012 Author Posted September 12, 2012 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
Tjalve Posted September 20, 2012 Posted September 20, 2012 Hi Water. First of all great UDF. Ive used it for several scripts. But there is one thin that i cant get working. I want to access several calenders in our public folders and then create a simple list of all items in a few diffrent caladers. But i cant get the _OL_FolderAccess part to work. Ive got this code: #Include <OutlookEX.au3> #Include <array.au3> Global $oOutlook = _OL_Open() $array =_OL_FolderAccess($oOutlook, "Gemensamma mappar - *my mailadress*") _arraydisplay($array) msgbox(0,@error,$array) _OL_Close($oOutlook) Im using a swedish version of Outlook 2010 and all the folders use the swedish name. Therefor the Public folders is called "gemensama mappar" So how should i do the Folder Access so that get all the info in my public folders dir?
water Posted September 20, 2012 Author Posted September 20, 2012 I am on vacation till the end of september. I will try to help you as soon as I return from Marocco. 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 September 26, 2012 Author Posted September 26, 2012 Can you please run this modified version of your example code?#Include <OutlookEX.au3> Global $oOutlook = _OL_Open() $array =_OL_FolderAccess($oOutlook, "\\Gemensamma mappar - *my mailadress*") msgbox(0,"Error of _OL_FolderAccess", "@error: " & @error & ", @extended: " & @extended) _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
SkoubyeWan Posted September 26, 2012 Posted September 26, 2012 May I suggest an improvement to one of your functions? It would be wonderful if _OL_ItemSave would allow some sort of flag to provide that the file created would have the date and time set to the same date and time as the email was sent or received. In this way, emails could be sorted in the directory by date and time and be in the correct order they were sent and received. Currently the file is saved with the date and time that the file is saved from outlook, rather than the sent or received date and time. Thank you for this wonderful UDF.
water Posted September 26, 2012 Author Posted September 26, 2012 Or you could use functions _OL_ItemGet to retrieve the send or receive date/time and then use function FileSetTime to set the date/time of the created file.How about that? 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
SkoubyeWan Posted September 26, 2012 Posted September 26, 2012 That is a very good work around. Having the functionality integrated would be more seamless however. Just a thought. Thanks.
water Posted September 27, 2012 Author Posted September 27, 2012 I have been thinking about it and decided not to implement it in the UDF. You can achieve what you need with the "workaround" I described above. To handle send or receive date thew way you need it would bloat the function. But if you like I can add the "workaround" to the example script. Sorry for denying your request. If you have other requests I will be happy to consider. 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 October 7, 2012 Author Posted October 7, 2012 Version 0.9.0.0 of the UDF has been released.Please test before using in production!For download please see my signature. 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
Tjalve Posted October 8, 2012 Posted October 8, 2012 (edited) Can you please run this modified version of your example code?#Include <OutlookEX.au3> Global $oOutlook = _OL_Open() $array =_OL_FolderAccess($oOutlook, "Gemensamma mappar - *my mailadress*") msgbox(0,"Error of _OL_FolderAccess", "@error: " & @error & ", @extended: " & @extended) _OL_Close($oOutlook) I tried running this: I got this response: "@error: 1,@extended: 0" Edited October 8, 2012 by Tjalve
water Posted October 8, 2012 Author Posted October 8, 2012 I see. You have to pass the folder type when using this type of folder name #Include <OutlookEX.au3> Global $oOutlook = _OL_Open() $array =_OL_FolderAccess($oOutlook, "\\Gemensamma mappar - *my mailadress*", $olFolderCalendar) msgbox(0,"Error of _OL_FolderAccess", "@error: " & @error & ", @extended: " & @extended) _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
Tjalve Posted October 12, 2012 Posted October 12, 2012 I tried but it doesnt matter what i enter in the folder part of the function. I always get an array witch containt 5 elemenst. 0 is a 5 (of course) 1 is empty 2 is just "0" 3 is a loooong string of numbers. 4 is also a long string of numbers (but not that long) 5 is *my emailadress* I dont get it. I need to read the info in the calenders under "Gemensamma Mappar - *my emailadress* - Alla gemensamma mappar - folder1 - recption".
Recommended Posts