Posting items to different folders programatically

P

Pat Curran

Hi
I have my calendar of events on a lan. I have a subdirectory of my calendar
called "Leave" that is also a calendar. It is used for all employee
vacations. I am trying to write to this directory and having problems. My
app keeps writing to the "Calendar" directory and not the Subdirectory of
the calendar "Leaves" directory. I have outlook open and am in the Leave
directory when I run this procedure:

PROCEDURE WriteLeavesToLeaveCalendar

local myOlApp, olMAPI, F, cEntryID, cStoreID, myFolder
myOlApp = new oleautoclient('outlook.application')
olMAPI = myOlApp.GetNameSpace("MAPI")
F = myOlApp.activeExplorer.currentFolder
cEntryID = f.entryID
cStoreID = f.storeID
myFolder = olMAPI.getFolderFromID( cEntryID, cStoreID )
myItem=myOlApp.CreateItem(1) && CalendarItem
myItem.Subject = "Leave: " + ltrim(rtrim(tmplv->Name))
myItem.Body = tmplv->type + chr(13) + tmplv->Address
myItem.Start = dtoc(tmplv->from)+ ' 00:09:00 AM'
myItem.End = dtoc(tmplv->to)+ ' 00:05:00 PM'
myItem.AllDayEvent = .t.
myItem.save()
RETURN
form.ReleaseLeaveCalendarItem( myOlApp )

Am I missing something? It posts the items....but only to the Calendar
Directory. is there a way programitacally I could temporarily change the
default directory to leave and then change it back again?
Thanks for any help
Pat
 
S

Sue Mosher [MVP]

CreateItem always creates an item in your default folder. Don't use it if
you want to create an item in a particular folder. Use MAPIFolder.Items.Add
instead.
 
P

Pat Curran

??? MAPIFolder.Items.Add ???

Hi Sue;
Thanks for your help, but I dont understand. Could you please write a
couple lines of code using my procedures so I can look at them and get the
hang of it? My ultimate goal will be to put these items to a public folder.
Thanks for your help.

Pat
 
S

Sue Mosher [MVP]

In VB/VBA/VBScript, it would be:

Set objItem = F.Items.Add

When in doubt, check the object browser: Press ALt+F11 to open the VBA
environment in Outlook, then press F2. You can highlight any item and press
F1 to get its Help topic, including code examples.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
P

Pat Curran

Thanks Sue...You have been so helpful. I couldn't have done it without you!

Pat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top