Cheepshooter Posted November 19, 2010 Posted November 19, 2010 Hi all,I just registered to ask about this one issue that is driving me crazy. I'm really new at AutoIt, but I've written a few scripts that have made my daily life a lot easier.This UDF is great! But I have this issue. At it's heart, I have these 3 basic lines:#Include "Outlook.au3"$oOutlook = _OutlookOpen()_OutlookDeleteMail($oOutlook, $sFolder = "\Junk E-Mail", $fDeleteMultipleMail = True, $fRemoveFromDeletedItems = False)And I get this error:ERROR: $sFolder: undeclared global variable._OutlookDeleteMail($oOutlook, $sFolder =~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^So then I add above _OutlookDeleteMail:$sFolder = "\Junk E-Mail"$fDeleteMultipleMail = True$fRemoveFromDeletedItems = FalseAnd get this error:Error in expression.:$oFilteredItems = $oMailItems.Restrict($sFilter)$oFilteredItems = ^ ERRORAny ideas? I'm sure I'm screwing something up.Thanks.
KingNED Posted November 22, 2010 Posted November 22, 2010 _OutlookDeleteMail($oOutlook, $sFolder = "\Junk E-Mail", $fDeleteMultipleMail = True, $fRemoveFromDeletedItems = False) should be: _OutlookDeleteMail($oOutlook,"\Junk E-Mail",'','', '', true, false)
AlmarM Posted November 22, 2010 Posted November 22, 2010 _OutlookDeleteMail($oOutlook, $sFolder = "\Junk E-Mail", $fDeleteMultipleMail = True, $fRemoveFromDeletedItems = False) should be: _OutlookDeleteMail($oOutlook,"\Junk E-Mail",'','', '', true, false) [offtopic] Lol, hey Michael [/offtopic] Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
KingNED Posted November 23, 2010 Posted November 23, 2010 [offtopic] Lol, hey Michael [/offtopic] lol hey Almighty Almar XD Now you see what I do during work
ICANSEEYOU7687 Posted November 30, 2010 Posted November 30, 2010 One thing I could really use this for, is that we have certain items that users can "Check out" through outlook. Things such as conference rooms. When You add an appointment, you can add items to the resources to do this. If I could use this to create an appaointment, and add a resource... And possibly, view the resources (I.E. If they are in use for that time already)
water Posted December 3, 2010 Posted December 3, 2010 Hi Wooltown, my understanding is that the functions always access the default folder of the specified type (mail, contacts ...) of my mailbox. It would be great if we could pass a parameter that specifies the mailbox and or folder to access. So I could access the appointments of another user or the conacts in a folder different from the default contacts folder. Often the functions return a lot of data (_OutlookGetContacts returns up to 45 properties). If the user could pass a parameter containing a comma separated list of properties he wants to be in the returned array could make things a bit easier. If nothing is passed a default list of properties will be returned. What do you think? 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 December 5, 2010 Posted December 5, 2010 (edited) Extending my last post I tried to adapt function _OutlookContacts soit can access all possible folder locations (default contacts folder of current user, subfolder of default contacts folder of current user, different contacts folder and subfolders of current user, public folder and subfolders, default contacts folder of another user, subfolder of default contacts folder of another user, different contacts folder and subfolders of another user)the performance of searching large folders is improvedthe properties to be returned can be defined freelythe filter (complex queries using exact match) and search (one property using partial match) properties can be defined and combined freelythe filter query can consist of complex expressionsHere you find what I have so far:expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OutlookGetContacts ; Description ...: Get contacts using Microsoft Outlook, returning an array of all information ; Syntax.........: _OutlookGetContacts($oOutlook[, $sFolder = ""[, $sRestrict = ""[, $sSearchName = ""[, $sSearchValue = ""[, $sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber"[, $sWarningClick = ""]]]]]]) ; Parameters ....: $oOutlook - Outlook object opened by a preceding call to _OutlookOpen() ; $sFolder - Optional: Folder to access. (default = contacts folder of current user) ; | "Rootfolder\Subfolder\Subfolder\...\Subfolder" to access any public folder or any contacts folder of the current user ; | "\\firstname name" to access the default contacts folder of another user ; | "\\firstname name\subfolder" to access a subfolder of the default contacts of another user ; | "\\firstname name\\subfolder" to access any subfolder of another user ; | "\subfolder" to access a subfolder of the default contacts of the current user ; $sRestrict - Optional: Filter text to restrict number of items returned ; $sSearchName - Optional: Name of the property to search for ; $sSearchValue - Optional: String value of the property to search for ; $sReturnProperties - Optional: Comma separated list of properties to return (default = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber") ; $sWarningClick - Optional: The Entire SearchString to 'OutlookWarning2.exe' (default = None) ; Return values .: Success - One based two-dimensional array with the properties specified by $sReturnProperties ; Failure - Returns 0 and sets @Error: ; |1 - You have to specifiy $sSearchname AND $sSearchValue or none of them ; |2 - $sWarningClick not found ; |3 - Could not resolve specified User in $sFolder ; |4 - Error accessing another users mailbox. For details check @extended ; |5 - Error accessing specified folder. For details check @extended ; |6 - Error accessing specified property. For details check @extended ; |7 - Error processing the restrict query. For details check @extended ; |9 - ObjEvent error ; Author ........: Wooltown ; Modified ......: 2010-12-04 by water: ; Remarks .......: Be sure to specify the values in $sReturnProperties and $sSearchname in correct case e.g. "FirstName" is valid, "Firstname" is invalid ; Search here to find how to define a query for $sRestrict: See http://msdn.microsoft.com/en-us/library/ff869597.aspx ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OutlookGetContactsEx($oOutlook, $sFolder, $sRestrict = "", $sSearchName = "", $sSearchValue="", $sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber", $sWarningClick = "") Local $oFolder, $bSearch = False If $sWarningClick <> "" Then If FileExists($sWarningClick) = 0 Then Return SetError(2, 0, "") Run($sWarningClick) EndIf ;Local $oSecurityManager = ObjCreate("AddinExpress.Outlook.SecurityManager") ;msgbox(0,"SM",IsObj($oSecurityManager)) ;$oSecurityManager.DisableOOMWarnings = True ;==> Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Local $oNamespace = $oOutlook.GetNamespace("MAPI") If $sFolder = "" Or (StringLeft($sFolder, 1) = "\" And _ ; No folder specified. Use default contacts folder StringMid($sFolder, 2, 1) <> "\") Then ; Folder starts with "\" = subfolder in default contacts folder $oFolder = $oNamespace.GetDefaultFolder($olFolderContacts) If $sFolder <> "" Then $aFolders = StringSplit(StringMid($sFolder, 2), "\") SetError(0) ; Reset error of StringSplit For $i = 1 To $aFolders[0] $oFolder = $oFolder.Folders($aFolders[$i]) If @error <> 0 Then Return SetError(5, @error, "") Next EndIf Else If StringLeft($sFolder, 2) = "\\" Then ; Access the calender of another user $aFolders = StringSplit(StringMid($sFolder, 3), "\") ; Split off Recipient $oDummy = $oNameSpace.CreateRecipient("=" & $aFolders[1]) ; Create Recipient. "=" sets resolve to strict $oDummy.Resolve ; Resolve If Not $oDummy.Resolved Then Return SetError(3, 0 , "") SetError(0) ; Reset error to 0 If $aFolders[0] > 1 And $aFolders[2] = "" Then ; Access any subolder of another user $oFolder = $oNamespace.GetSharedDefaultFolder($oDummy, $olFolderContacts).Parent Else ; Access a subolder of the default contacts of another user $oFolder = $oNamespace.GetSharedDefaultFolder($oDummy, $olFolderContacts) EndIf If @error <> 0 Then Return SetError(4, @error, "") Else $aFolders = StringSplit($sFolder, "\") ; Folder specified. Split and get the object $oFolder = $oNamespace.Folders($aFolders[1]) If @error <> 0 Then Return SetError(5, @error, "") EndIf If $aFolders[0] > 1 Then ; Access subfolders For $i = 2 To $aFolders[0] If $aFolders[$i] <> "" Then $oFolder = $oFolder.Folders($aFolders[$i]) If @error <> 0 Then Return SetError(5, @error, "") EndIf Next EndIf EndIf If ($sSearchName <> "" And $sSearchValue = "") Or ($sSearchName = "" And $sSearchValue <> "") Then Return SetError(1, 0, "") If $sSearchName <> "" Then $bSearch = True Local $asReturnProperties = StringSplit(StringStripWS($sReturnProperties, 8), ",") Local $asContacts[$oFolder.Items.Count+1][$asReturnProperties[0]] = [[0, $asReturnProperties[0]]], $sTemp If $sRestrict = "" Then $sRestrict = '[OutlookVersion] <> ""' ; Dummy filter to retrieve all items $oContacts = $oFolder.Items.Restrict($sRestrict) If @error <> 0 Then Return SetError(7, @error, "") For $oContact In $oContacts If $oContact.Class <> $olContact Then ContinueLoop If $bSearch And StringInStr($oContact.ItemProperties.Item($sSearchName).value, $sSearchValue) = 0 Then ContinueLoop $asContacts[0][0] += 1 For $iIndex = 1 To $asReturnProperties[0] ; Fill array with the specified properties $asContacts[$asContacts[0][0]][$iIndex - 1] = $oContact.ItemProperties.Item($asReturnProperties[$iIndex] ).value If @error <> 0 Then Return SetError(6, @error, "") Next Next ReDim $asContacts[$asContacts[0][0] + 1][$asReturnProperties[0]] If @error <> 0 Then Return SetError(9, @error, "") ;$oSecurityManager.DisableOOMWarnings = True Return $asContacts EndFunc ;==>_OutlookGetContactsExExamples:; Example 1 - Current User - Default contacts folder ; Filter all items with firstname "Mathias" and return properties firstname, lastname and fullname $sFolderToAccess = "" $aContacts = _OutlookgetContactsEx($oOutlook, $sFolderToAccess, '[FIRSTNAME] = "Mathias"', "", "", "FirstName,LastName,FullName") ConsoleWrite("@error: " & @error & ", @extended: " & @extended & @CRLF) _ArrayDisplay($aContacts) ; Example 2 - Other User - Default contacts folder ; Filter all items with homeaddresscity "New York" and companyname "IBM". The department contains "IT". Return properties firstname, lastname and fullname $sFolderToAccess = "\\name firstname" $aContacts = _OutlookgetContactsEx($oOutlook, $sFolderToAccess, '[HomeAddressCity] = "New York" and [CompanyName] = "IBM"', "Department", "IT", "FirstName,LastName,FullName") ConsoleWrite("@error: " & @error & ", @extended: " & @extended & @CRLF) _ArrayDisplay($aContacts)What do you think?Is this an approach that can be extended to all functions? Edited December 5, 2010 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 Â
Steveiwonder Posted January 12, 2011 Posted January 12, 2011 Hey..been using this UDF for some time and and its awesome, I've made changes and added my own methods however recently something changed which i think has been added by MS. I get this error...I'm not aware of the machine doing any updates but clearly something has changed, i never used to get it.The function caused this to popup is _OutlookGetMail() ;I guessing i would have to add the program to the COM addin list? If thats the case it could prove difficult as im not admin. I can use the "Allow" acces for 10mins option which works but if anyone is aware of a work around that would also be nice.ThanksSteveo They call me MrRegExpMan
water Posted January 12, 2011 Posted January 12, 2011 I think setting the parameter $sWarningClick of _OutlookGetMail() to the full path to OutlookWarning2.exe will do the trick. You can find details on page 1 of this thread. 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 Â
SeF Posted January 14, 2011 Posted January 14, 2011 Does anyone know how can I insert table and format texts on body parameter from _OutlookSendMail.A piece from my script:$oOutlook = _OutlookOpen() _OutlookSendMail($oOutlook, "email@generic.com", "", "", "Subject/Title", "Body text. Here I want to add a 5x1 table) ; Thanks!
water Posted January 14, 2011 Posted January 14, 2011 Set the parameter $iBodyFormat to $olFormatHTML and insert HTML into the body of your mail. Please check the function _OutlookSendMail in the UDF. If necessary please change line $oMessage.Body = $sBodytoIf $iBodyFormat = $olFormatHTML Then $oMessage.HTMLBody = $sBody Else $oMessage.Body = $sBody EndIf 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 Â
SeF Posted January 20, 2011 Posted January 20, 2011 Set the parameter $iBodyFormat to $olFormatHTML and insert HTML into the body of your mail. Please check the function _OutlookSendMail in the UDF. If necessary please change line $oMessage.Body = $sBodytoIf $iBodyFormat = $olFormatHTML Then $oMessage.HTMLBody = $sBody Else $oMessage.Body = $sBody EndIf It worked! Thanks!!
darkleton Posted February 15, 2011 Posted February 15, 2011 i know this is probably such a basic question, but when i do _outlookgetmail and it returns the array of how many items and how many unread items, how do i extract JUST the unread items? I want it to display a msgbox saying "you have x unread emails" but if i remember the unread email count is row 0 column 2 (i think) so how do i get it to output that? Thanks mike
water Posted February 15, 2011 Posted February 15, 2011 (edited) Hi darkleton, if I understand the UDF correctly element[0][1] represents the number of unread mails. If you then want to filter the unread mails from the array check element[row][12] for True. Or set $fOnlyReturnUnread to True and the function only returns unread mails. HTH BTW: It might be too early but an extended Outlook UDF with a different approach is in the making. It will remove all limitations of the current UDF. The downside will be that they are not compatible so all your scripts will have to be rewritten. Edited February 15, 2011 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 Â
darkleton Posted February 15, 2011 Posted February 15, 2011 hi water. so would this work if it only returns unread email count? $oOutlook = _OutlookOpen() $xx = _OutlookGetMail($oOutlook,$olFolderInbox ,False,"","","","","","",True,"",0,True) msgbox(0,'',"you have " & $xx & " unread email/s") Thanks
water Posted February 15, 2011 Posted February 15, 2011 (edited) No, the function always returns an array. But this should work: #include <Outlook.au3> $oOutlook = _OutlookOpen() $xx = _OutlookGetMail($oOutlook, $olFolderInbox, False, "", "", "", "", "", "", True, "", 0, True) MsgBox(0, '', "You have a total of " & $xx[0][0] & " mails in your inbox. " & $xx[0][1] & " of them are unread") Edited February 15, 2011 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 Â
darkleton Posted February 16, 2011 Posted February 16, 2011 thanks a lot. i never really got to grips with arrays (as i've shown hehe!)
kmosh1 Posted February 17, 2011 Posted February 17, 2011 Hi All, First, very nice and helpful UDF... I'm trying to create an appointment with sevral attendies... I didn't see this option. Can anyone help?
water Posted February 17, 2011 Posted February 17, 2011 (edited) Hi All,First, very nice and helpful UDF...I'm trying to create an appointment with sevral attendies...I didn't see this option. Can anyone help?Wooltown (the author of this UDF) and I am currently extending the functionality of the Outlook UDF. Most likely it will be a complete rewrite with a completely different approach. The tests with the first alpha version start next week.Now you have to decide what to do:If you need it right now then you can create the appointment using the current UDF. The attendees have to be added manually (no big deal)Wait till we release the extended UDFUse the alpha version. But you might find some bugsWhat do you want to do? Edited February 17, 2011 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 Â
kmosh1 Posted February 17, 2011 Posted February 17, 2011 (edited) Wooltown (the author of this UDF) and I am currently extending the functionality of the Outlook UDF. Most likely it will be a complete rewrite with a completely different approach. The tests with the first alpha version start next week.Now you have to decide what to do:If you need it right now then you can create the appointment using the current UDF. The attendees have to be added manually (no big deal)Wait till we release the extended UDFUse the alpha version. But you might find some bugsWhat do you want to do?Hi Water,Nice to know this is still worked on...Actually, I do need it as automated, as I need to read an Excel file, and add multiple appointments to multiple reciepients according to the file...I would like to try the alpha ver...I did add a parameter $sAttendies, and the below line: If $sAttendies <> "" Then $oNote.Recipients.Add($sAttendies) This does add the attendy, but as unresolved name. Also added the send command after the save: $oNote.Save $oNote.Send But it's not actually sent...Thanks for replying so fast.Kmosh. Edited February 17, 2011 by kmosh1
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