anixon Posted June 27, 2010 Posted June 27, 2010 This object does not fail in Windows Vista;//Create the Outlook Object Items Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Local $oNamespace = $oOutlook.GetNameSpace("MAPI") Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox) Local $oFolders = $oInbox.Parent.Folders ;//Count the number of Email cycles to process [One Cycle per Email] $Items = $oInbox.Items.Count ;//Initalise Processed Email Folder [sEmailSMS] For $oFolder In $oFolders If String($oFolder.Name) = $sSMSFolder Then $oSMSFolder = $oFolder EndIf NextIf I run the code in a Windows XP I get the following messagec:\SMS_Server\Includes\sAPIOutlook.au3 (226) : ==> Error in expression.:Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox)Local $oInbox = ^ ERRORHelp is always appreciated Ant..
Bert Posted June 27, 2010 Posted June 27, 2010 Is your version of Outlook on both PCs the same? The Vollatran project My blog: http://www.vollysinterestingshit.com/
anixon Posted June 28, 2010 Author Posted June 28, 2010 (edited) Is your version of Outlook on both PCs the same? Yes I am running the same version of Outlook on both XP and Vista. This code actually works in Vista. #include <Array.au3> #include <GUIConstants.au3> Const $olFolderInbox = 6 Global $oOutlook, $oSMSFolder, $oItems $oOutlook = ObjCreate("Outlook.Application") Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Local $oNamespace = $oOutlook.GetNameSpace("MAPI") Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox) Local $oFolders = $oInbox.Parent.Folders ;//Count the number of Email cycles to process [One Cycle per Email] $Items = $oInbox.Items.Count For $oFolder In $oFolders If String($oFolder.Name) = $oSMSFolder Then $oSMSFolder = $oFolder EndIf Next $oItems = $oInbox.Items While 1 For $oItem In $oItems Local $Address = $oItem.SenderEmailAddress MsgBox(0, "", $Address) Next ExitLoop WEnd I am not sure what the For $oFolder In $oFolders is about it looks incomplete to me. Is it a check that the inbox folder exists in which case their should be an exitloop?? Ant.. Edited June 28, 2010 by anixon
Juvigy Posted June 28, 2010 Posted June 28, 2010 The above code works for me. XP / outlook 2007 What error exactly do you get?
water Posted June 28, 2010 Posted June 28, 2010 Did you have a look at the Outlook UDF? Maybe the function you need is already included. Our you might get a hint from the source code. 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
anixon Posted June 28, 2010 Author Posted June 28, 2010 (edited) Thanks to all subscribers for assistance. As it turned out my issue was I had not applied a global setting to one of the variables which would bring me to the conclusion that it was not XP Vista OS related I have been running the routine in a loop now for nearly 24 hours without it failing so I am happy that the code does what it is designed to do. Thanks for pointing me to the Wooltown Outlook UDF which I had forgotten about. For those building Outlook related scripts an excellent resource when constructing object orientated outlook routines. Ant.. Edited June 28, 2010 by anixon
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