Sign in to follow this  
Followers 0
HighlanderSword

OUtlook UDF _OutlookFolderAdd

4 posts in this topic

Hello,

Im using the outlook udf and am having issues when adding folders, I took the example

#Include "C:\Work Data\Downloads\outlook\Outlook.au3"

$oOutlook = _OutlookOpen()

$xx = _OutlookFolderAdd($oOutlook,$olFolderInbox & "\Old\Missing\")

The code snippet only creates the Old folder and NOT the subfolder underneath it ( Missing).

I also want to be able to specify what PST folder to use to create the new folders in, so for example I have an opened PST in Outlook named examples,

So How would I add the \Old\Missing folders to the root of the Example pst folder I have opened.

I tried doing

$xx = _OutlookFolderAdd($oOutlook,"Examples\Old\Missing\")

$xx = _OutlookFolderAdd($oOutlook,"\Examples\Old\Missing\")

$xx = _OutlookFolderAdd($oOutlook,"\\Examples\Old\Missing\")

All failed with error code of 2 - inidcating it could not find the root folder"

Please let me know if anyone has any ideas.

Thanks

Paul

Share this post


Link to post
Share on other sites



Have you tried to split

$xx = _OutlookFolderAdd($oOutlook,$olFolderInbox & "\Old\Missing\")

in 2 lines ? like

$xx1 = _OutlookFolderAdd($oOutlook,$olFolderInbox & "\Old\")

$xx2 = _OutlookFolderAdd($oOutlook,$olFolderInbox & "\Old\Missing\")

as technically those are 2 folders you want to create.

Share this post


Link to post
Share on other sites

Hello,

Yes that will create the 2 folders.

Is there any way ti specify the PST folder to place it in ?

Share this post


Link to post
Share on other sites

There is a way but it is complicated and you will have to use CDO.

It is not possible with the Outlook udf. You can check the CDO methods like:

$objSession = ObjCreate("MAPI.Session")
$objSession.Logon("","",False,False)
$objInfoStores = $objSession.InfoStores
FOR $element IN $objInfoStores
        $objTopFolder = $element.RootFolder
    $FolderID = $element.ID
    $Folders = $element.RootFolder.Folders
    ConsoleWrite($element.ID&@CRLF)
    ConsoleWrite($element.Name&@CRLF)
NEXT

This will get the ID's and Name's of all inbox's and pst's.

You will need to have CDO installed. I have installed it from here:

icrosoft Collaboration Data Objects 1.2.1 installer

April 2006

© Microsoft Corporation. All Rights Reserved.

The release notes for Microsoft Collaboration Data Objects 1.2.1 are available on the Release Notes Web page at http://go.microsoft.com/fwlink/?LinkId=178082.

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  
Followers 0