Author Topic: MAPI Calendar Appointment retreival issue  (Read 5169 times)

rgouette

  • Newbie
  • *
  • Posts: 12
  • I've been in WB since 2003 ish
    • Gouette
MAPI Calendar Appointment retreival issue
« on: July 21, 2015, 09:49:09 am »
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

  • Full Member
  • ***
  • Posts: 125
Re: MAPI Calendar Appointment retreival issue
« Reply #1 on: July 21, 2015, 06:57:31 pm »
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
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

  • Tech Support
  • *****
  • Posts: 4382
    • WinBatch
Re: MAPI Calendar Appointment retreival issue
« Reply #2 on: July 22, 2015, 08:32:33 am »
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

  • Newbie
  • *
  • Posts: 12
  • I've been in WB since 2003 ish
    • Gouette
Re: MAPI Calendar Appointment retreival issue
« Reply #3 on: July 22, 2015, 10:06:05 am »
thanks so much for the replies lads,
it does fail on the :
Code: [Select]
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

  • Full Member
  • ***
  • Posts: 125
Re: MAPI Calendar Appointment retreival issue
« Reply #4 on: July 22, 2015, 05:21:34 pm »
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

  • Newbie
  • *
  • Posts: 12
  • I've been in WB since 2003 ish
    • Gouette
Re: MAPI Calendar Appointment retreival issue
« Reply #5 on: July 23, 2015, 06:50:24 am »
thanks mate, I'll dig deeper..
Rich