Outlook and non-default folder

Einbindung von Office-Komponenten wie Word, Excel usw.

Moderator: Moderatoren

Antworten
simofranz
Rookie
Rookie
Beiträge: 11
Registriert: Mo, 26. Sep 2016 17:11

Outlook and non-default folder

Beitrag 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
Benutzeravatar
Wolfgang Ciriack
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2932
Registriert: Sa, 24. Sep 2005 9:37
Wohnort: Berlin
Hat sich bedankt: 13 Mal
Danksagung erhalten: 34 Mal
Kontaktdaten:

Re: Outlook and non-default folder

Beitrag 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
......
Viele Grüße
Wolfgang
simofranz
Rookie
Rookie
Beiträge: 11
Registriert: Mo, 26. Sep 2016 17:11

Re: Outlook and non-default folder

Beitrag 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
Benutzeravatar
Wolfgang Ciriack
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2932
Registriert: Sa, 24. Sep 2005 9:37
Wohnort: Berlin
Hat sich bedankt: 13 Mal
Danksagung erhalten: 34 Mal
Kontaktdaten:

Re: Outlook and non-default folder

Beitrag 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") ?
Viele Grüße
Wolfgang
simofranz
Rookie
Rookie
Beiträge: 11
Registriert: Mo, 26. Sep 2016 17:11

Re: Outlook and non-default folder

Beitrag 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 ?
Benutzeravatar
AUGE_OHR
Marvin
Marvin
Beiträge: 12903
Registriert: Do, 16. Mär 2006 7:55
Wohnort: Hamburg
Hat sich bedankt: 19 Mal
Danksagung erhalten: 44 Mal

Re: Outlook and non-default folder

Beitrag 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
gruss by OHR
Jimmy
Antworten