RodT Posted May 29, 2008 Share Posted May 29, 2008 This script is my first attempt at accessing Outlook from AutoIt, based on MS documentation and examples found here. It dies at the line marked in the code (without reaching the "If @error ..." just below). What I'm attempting to do here is to list all the top-level folders. CODE$otl = ObjCreate("Outlook.Application") If @error Then Die("Cannot create application object") $nms = $otl.GetNameSpace("MAPI") If @error Then Die("Cannot access namespace object") $fds = $nms.Folders If @error Then Die("Cannot access folders object") $i = 0 Dim $fname[100] $fld = $fds.GetFirst If @error Then Die("Cannot access folders.GetFirst method") $fname[$i] = $fld.Name ;<-----------------------------------------Program fails HERE If @error Then Die("Cannot access folder name property") $i += 1 While 1 $fld = $fds.GetNext If @error Then ExitLoop $fname[$i] = $fld.Name $i += 1 WEnd $fld = 0 $fds = 0 $nms = 0 $otl = 0 $msg = $fname[0] $j = 1 While $j < $i $msg &= (@CRLF & $fname[$j]) $j += 1 WEnd MsgBox(0, "Results", $msg) Func Die($pmsg) MsgBox(0, "Error", $pmsg) Exit EndFunc Here are the messages output from AutoIt when I run it: CODE>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\...\Outlook_test1.au3" C:\Documents and Settings\...\Outlook_test1.au3 (22) : ==> The requested action with this object has failed.: $fname[$i] = $fld.Name $fname[$i] = $fld.Name^ ERROR ->10:15:22 AutoIT3.exe ended.rc:1 +>10:15:23 AutoIt3Wrapper Finished >Exit code: 1 Time: 1.303 Thanks for your help!!!!! Link to comment Share on other sites More sharing options...
Developers Jos Posted May 30, 2008 Developers Share Posted May 30, 2008 First thing to do is to add the ComErrorHandler as described in the Helpfile. PS.This belongs in the Support forum. This section is for "other"programming languages that use AutoItX Moved Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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