Jump to content
Sign in to follow this  

Outlook - Cannot access MAPIFolder.Name property

Recommended Posts


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.

$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


$fld = 0

$fds = 0

$nms = 0

$otl = 0

$msg = $fname[0]

$j = 1

While $j < $i

$msg &= (@CRLF & $fname[$j])

$j += 1


MsgBox(0, "Results", $msg)

Func Die($pmsg)

MsgBox(0, "Error", $pmsg)



Here are the messages output from AutoIt when I run it:

>Running:(\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!!!!! :)

Share this post

Link to post
Share on other sites

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


Jos :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this