Solved

Using VBA to update a shared calendar

Posted on 2009-07-08
8
865 Views
Last Modified: 2013-12-25
This article from MSDN talks about how to automate Outlook using VB:
http://support.microsoft.com/kb/220595
But is it possible to use VB to add calendar events on a shared calendar on an Exchange server as opposed to the user's default Outlook calendar? If so, how would one set a reference to a calendar in a location such as "https://email.institution.edu/public/Sub%20Folder/?Cmd=contents"?
0
Comment
Question by:NashVegas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 20

Expert Comment

by:darbid73
ID: 24803244
does this help you

Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objFolder As Outlook.MAPIFolder
    Dim objDummy As Outlook.MailItem
    Dim objRecip As Outlook.Recipient
    Dim objInvite As Outlook.Recipient
    Dim objAppt As Outlook.AppointmentItem
    Dim strMsg As String
    Dim strName As String
    On Error Resume Next
    
    ' ### name of person whose Calendar you want to use ###
    strName = "name@name.com"
    
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objRecip = objNS.CreateRecipient(strName)
    
 
    Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
        
        If Not objFolder Is Nothing Then
            Set objAppt = objFolder.Items.Add
            If Not objAppt Is Nothing Then
                With objAppt
                    .MeetingStatus = olMeetingRequest
                    .MeetingStatus = olMeeting
                    .Subject = "Donald Duck's Birthday"
                    .Start = "07/03/2009 17:00:00"
                    .Body = "YOU ARE A WINNER"
                    .Duration = 1400
                    .Location = "France Paris"
                    .ReminderMinutesBeforeStart = 60
                    .BusyStatus = olTentative
                    .RequiredAttendees = "invitee@name.com"
                    .Display
                End With
            End If
        End If
        
        
    Set objApp = Nothing
    Set objNS = Nothing
    Set objFolder = Nothing
    Set objDummy = Nothing
    Set objRecip = Nothing
    Set objAppt = Nothing

Open in new window

0
 

Author Comment

by:NashVegas
ID: 24803359
Thank you for the prompt response. It looks to me that this code provides a way to send an appointment item to a specific user which is something I will definitely have a use for, but not the solution in this particular case. Unless the URL for the shared calendar can be used in place of "name@name.com". Is there a different library function similar to "CreateRecipient" that could be used to point to the shared calendar rather than an indiviual user's calendar?
0
 
LVL 20

Expert Comment

by:darbid73
ID: 24803459
I must admit that I am not familiar with a URL shared calendar but the code I gave you will definately allow you to enter appointments on a shared calendar.

Note here...

Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)

The key to this is for you to get the right name of the shared folder.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 

Author Comment

by:NashVegas
ID: 24803659
So in this scenario, a specific user would have to create a calendar and share it with the other users who need access. Then "name@name.com" would be the calendar owner's email address and "GetSharedDefaultFolder" would reference the specific calendar they are sharing, correct? I think this might be okay (I'll have to run it by the users). But unless I'm missing something, I don't see where in the code the name of the shared calendar would be set. I would expect "GetSharedDefaultFolder" to mean "the default calendar for the specified user". So how would I define which of the user's calendars is the calendar to which I want to add an appointment?
0
 
LVL 20

Expert Comment

by:darbid73
ID: 24803963
I have only worked with shared calendars, where USER_A has given USER_B rights to their calendar.  USER_B then has multiple calendars which they can see - It appears in the "Other Calendars" section.  I have not seen your URL calendar but I imagine that if a user can manually add an item to this URL calendar then it must be a calendar folder on this users outlook - it might even appear as an "Other Calendar".

But your key to getting a users calendar is by the Recipient.

Your code will fail if the USER_B tries to get USER_A's calendar and USER_A has not allowed it.
0
 

Author Comment

by:NashVegas
ID: 24804125
I am certain that in our case, USER_A will not want these calendar events cluttering their default calendar. If USER_A created a second calendar called "SharedCalendar" and gave other users permissions to view that calendar, then that is the only way this solution might be acceptable.
0
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 24804339
I must say again I am both guessing and cannot not test your situation as I do not have it.  But I would think that there is no difference to the example I gave you and your case.  It is just that USER_A in your case is not also the personal calendar of anyone.

In your case USER_B (and all other users) can see this calendar right, and can manually add appointments?

If yes I am guessing that this calendar has a name.  Once you have this name you can get this folder by its name.

 
0
 

Author Comment

by:NashVegas
ID: 24804959
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23972317.html?sfQueryTermInfo=1+appoint+calendar+set

I found another thread that answered my question. I had searched before but somehow could not find this until now. I'll give you credit for helping me get on the right path. Thanks,
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question