MAPI Calendar Appointment retreival issue

Started by rgouette, July 21, 2015, 09:49:09 AM

Previous topic - Next topic

rgouette

My goal is: Retrieve the current days Calendar appointments, from a shared calendar called "Vacation - Calendar"

Trying to make use of the following example: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~and~Outlook+Get~list~of~appointments.txt

I thought I could define the specifc calendar in question as so:
MyVacaCalendar = objCalendar.Folders("Vacation - Calendar")

But it throws ERROR 1261 "...An object could not be found"

Thoughts?
This Calendar is sitting in a folder called "Other Calendars"
Tried to get a loop going, to see folder names, but just not getting on well...
thoughts?
Thanks much for any help,
Rich

....IFICantBYTE

Here's a modified small part of the script you are referring to in the Tech Database... try inserting it into the script you are playing with and see if it helps.

Basically, I think you need to create a "recipient" object first - ie. the shared calendar's owner name and then set the Calendar and Item objects to that object's shared folder before you try accessing any other properties.

Change "Training Room Bookings" to whatever the shared calendar you are after is called.


/// SNIP/// - only part of the larger script

Code (winbatch) Select
olPrivate        = 2
olFolderCalendar = 9

objOutlook   = ObjectOpen("Outlook.Application")
objMAPI      = objOutlook.GetNameSpace("MAPI")
;objCalendar = objMAPI.GetDefaultFolder(olFolderCalendar)
;objItems    = objCalendar.Items
;objCurrent   = objMAPI.CurrentUser
objCurrent = objMAPI.CreateRecipient("Training Room Bookings")
objCalendar = objMAPI.GetSharedDefaultFolder(objCurrent, olFolderCalendar)
objItems = objCalendar.Items


objName      = objCurrent.Name
message("",objName)
;objName      = "Joe Shmoe"


/// SNIP/// only part of the larger script referenced in the Tech Database
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

td

Nice suggestion.  Here is a link to the method in the Outlook programming model documentation.   Outlook's online programming model documetation is a very good place to go when you want to figure out how to do something using Outlook's COM Automation objects.

https://msdn.microsoft.com/en-us/library/office/ff869575.aspx
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

rgouette

thanks so much for the replies lads,
it does fail on the :
objCalendar = objMAPI.GetSharedDefaultFolder(objCurrent, olFolderCalendar)

I wonder: is that because when I view the properties for the calendar, it's Location is listed as: "\\SharePoint Lists"
Is there a connection component that's missing getting to that location vs my 'default' calendar, whose
Location is:  \\rgouette@butlerbros.com

?
Thoughts?
Rich

....IFICantBYTE

I tested my suggestion against a shared calendar I have access to, and it worked, but it is a "standard" shared calendar from another Exchange user.
Unfortunately we don't have SharePoint here, so I can't test for that.... In Outlook, I can see an "Other Calendars" parent item in my list of calendars, but it has nothing under it.
My shared calendars appear under "My Calendars" with their location as "\\TheUserName" and one under "Shared Calendars" with just a "\\" as the location.

I'm pretty sure you should be able to get to it somehow... you might need to reference it directly instead of using GetSharedDefaultFolder or similar.... as Tony said, do a bit of looking around on Microsoft and other sites for the info.

Ok... did a quick search and found these sites with some related info... you should be able to work something out after looking at these I think...

http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_27674828.html
http://www.outlookcode.com/codedetail.aspx?id=1836
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

rgouette