Seite 1 von 1

Outlook and non-default folder

Verfasst: Mo, 26. Sep 2016 17:24
von simofranz
Hi,
i can't understand how to access a non-default folder of outlook, such as:

Outlook
|- contacts
|- calendar
|- myPersonalCalendar (<-----)
|- ecc.


from VB:

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = _myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myNewFolder = myFolder.Folders("myPersonalCalendar")

from XB:
oNameSpace := oOutlook:GetNamespace( "MAPI" )
oAppointment := oNameSpace:getDefaultFolder( oLFolderCalendar )
??????

many thanks for your suggestions

Re: Outlook and non-default folder

Verfasst: Mo, 26. Sep 2016 19:50
von Wolfgang Ciriack
Hi,
i only have a solution to pick a folder:

Code: Alles auswählen

oNS := oOutlook:GetNamespace( "MAPI" )
oFolder:=oNS:PickFolder() 
if oFolder:DefaultItemType<>olAppointmentItem          
      ** no appointment folder
.......
myId:=oFolder:EntryID
.....
if empty(myId)
   oAppoint:=oNS:GetDefaultFolder(olFolderCalendar)
else
   oAppoint:=oNS:GetFolderFromID(myid)
endif
.....
nOlCount:=oAppoint:items:count
......

Re: Outlook and non-default folder

Verfasst: Fr, 30. Sep 2016 11:27
von simofranz
but searching online the method PickFolder :

The Pick Folder dialog box is a modal dialog box which means that code execution will not continue until the user either selects a folder or cancels the dialog box

I'll want to access on my non-default folder without opening a dialog box

Re: Outlook and non-default folder

Verfasst: Fr, 30. Sep 2016 11:56
von Wolfgang Ciriack
Do the folder select in you config and save the ID (myid). Then you can pass the id to oNS:GetFolderFromID(myid).
Perhaps there is a function oNS:GetFolderFromName("myfolder") ?

Re: Outlook and non-default folder

Verfasst: Fr, 30. Sep 2016 12:07
von simofranz
I've found this:

https://msdn.microsoft.com/en-us/librar ... e.11).aspx

Using the Folders Object
Use the Folders property to return the Folders object from a NameSpace object or another MAPIFolder object.

Use Folders(index), where index is the name or index number, to return a single MAPIFolder object. Folder names are case-sensitive.

The following Visual Basic for Applications (VBA) example returns the folder named Old Contacts.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
myNameSpace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myFolder.Folders("Old Contacts")


The following Visual Basic for Applications example returns the first folder.
Set myNewFolder = myFolder.Folders(1)


But i can't write in correct xbase format.
Can you help me ?

Re: Outlook and non-default folder

Verfasst: Mo, 18. Jun 2018 21:19
von AUGE_OHR
simofranz hat geschrieben: Fr, 30. Sep 2016 12:07 The following Visual Basic for Applications example returns the first folder.

Code: Alles auswählen

Set myNewFolder = myFolder.Folders(1)
Syntax is right but for Xbase++ you must find "right" Object -> Root of ol* Constante-> o:Parent