Outlook and non-default folder

Einbindung von Office-Komponenten wie Word, Excel usw.

Moderator: Moderatoren

Outlook and non-default folder

Beitragvon simofranz » Mo, 26. Sep 2016 17:24

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
simofranz
Rookie
Rookie
 
Beiträge: 8
Registriert: Mo, 26. Sep 2016 17:11

Re: Outlook and non-default folder

Beitragvon Wolfgang Ciriack » Mo, 26. Sep 2016 19:50

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
Benutzeravatar
Wolfgang Ciriack
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
 
Beiträge: 2235
Registriert: Sa, 24. Sep 2005 9:37
Wohnort: Berlin

Re: Outlook and non-default folder

Beitragvon simofranz » Fr, 30. Sep 2016 11:27

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
simofranz
Rookie
Rookie
 
Beiträge: 8
Registriert: Mo, 26. Sep 2016 17:11

Re: Outlook and non-default folder

Beitragvon Wolfgang Ciriack » Fr, 30. Sep 2016 11:56

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
Benutzeravatar
Wolfgang Ciriack
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
 
Beiträge: 2235
Registriert: Sa, 24. Sep 2005 9:37
Wohnort: Berlin

Re: Outlook and non-default folder

Beitragvon simofranz » Fr, 30. Sep 2016 12:07

I've found this:

https://msdn.microsoft.com/en-us/library/office/aa210918(v=office.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 ?
simofranz
Rookie
Rookie
 
Beiträge: 8
Registriert: Mo, 26. Sep 2016 17:11


Zurück zu MS Office

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast