Linking to Outlook Calander from Access

Hello,
I want to populate a Outlook calander based on dates I grab from a MS Access Form.  I found code to populate my Outlook calander (http://support.microsoft.com/?kbid=209963).  However I need to populate a public Outlook calander.  How do I do this?  


Thanks!
AronMcDAsked:
Who is Participating?
 
Chris BottomleyConnect With a Mentor Software Quality Lead EngineerCommented:
Cannot say what you are using elsewhere so I haven't deleted anything just used:

Set MyPublicFolder = objOl.session.getdefaultfolder(18).folders(strPublicFolder)

To get to the indicated public folder

Chris
strPublicFolder = ("XL Vacation Schedule")
     
    If Len(strPublicFolder) > 0 Then
     
    Set objOL = CreateObject("Outlook.Application")
    Set mNameSpace = objOL.GetNamespace("MAPI")
    Set objCalFolder = mNameSpace.Folders("Public Folders")
    Set AllPublicFolders = objCalFolder.Folders("All Public Folders")
    Set MyPublicFolder = objOl.session.getdefaultfolder(18).folders(strPublicFolder)
    Set colCalendar = MyPublicFolder.Items
    Set objAppt = colCalendar.Add

    With objAppt
            .Start = Me.StartDate
            .End = Me.EndDate

            .Subject = Me.EmployeeName & " " & Me.RequestTypeID.Column(1) & " " & Me.HoursOfVacation & " hrs" '& " hrs Vacation."


            .Save
            .Close (olSave)
            End With
            'Release the AppointmentItem object variable.
            Set objAppt = Nothing
    End If

Open in new window

0
 
Jeffrey CoachmanMIS LiasonCommented:
please click the "request Attention" link and ask the the Outlook zone be added to this question.
0
 
Mark WillsTopic AdvisorCommented:
Not sure about global / public mailboxes, but I did recently help with an Article : http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4617-Outlook-View-Control-OVC-part-two-Changing-folders-and-interacting-programmatically-Access-2007.html

The Author of that article might be able to help you - will leave a message for you.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Chris BottomleySoftware Quality Lead EngineerCommented:
In the referenced code it uses:

        Set objAppt = objOutlook.CreateItem(olAppointmentItem)
try using:
dim fldr as object

'        Set objAppt = objOutlook.CreateItem(olAppointmentItem) ' Keeps the original line for reference!
        Set objAppt = objOutlook.session.getdefaultfolder(18).folders("My Calendar").items.add

Note if the calendar is somewhere down the tree then assuming in the public folders hierarchy it is:

\Global Folder\Local Folder\Me\My Calendar then separate them out with 'folders i.e.

objOutlook.session.getdefaultfolder(18).folders("Global Folder").folders("Local Folder").folders("Me").folders("My Calendar").items.add

Chris
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Ignore the line dim fldr ... cut and paste error and didn't see it on my read through!

Chris
0
 
conagramanCommented:
i think chris is right. we will need to know the "path"/folder name
AronMcD
do you know the name of the "path"/folder of your calendar?
it might be something like "Public Folders\public calendar" or like chris said "global folder\Calendar"
0
 
AronMcDAuthor Commented:
I'm sorry for the hold up.  I'm waiting to get access to the public calendar so I can test.  Below is the code I have but won't know if it works until I'm able to test.  I have no idea if it will work or not.   Maybe you could look at Chris and have an idea if it will work.  

strPublicFolder = ("XL Vacation Schedule")
     
    If Len(strPublicFolder) > 0 Then
     
    Set objOL = CreateObject("Outlook.Application")
    Set mNameSpace = objOL.GetNamespace("MAPI")
    Set objCalFolder = mNameSpace.Folders("Public Folders")
    Set AllPublicFolders = objCalFolder.Folders("All Public Folders")
    Set MyPublicFolder = AllPublicFolders.Folders("XL Vacation Schedule")
    Set colCalendar = MyPublicFolder.Items
    Set objAppt = colCalendar.Add

    With objAppt
            .Start = Me.StartDate
            .End = Me.EndDate

            .Subject = Me.EmployeeName & " " & Me.RequestTypeID.Column(1) & " " & Me.HoursOfVacation & " hrs" '& " hrs Vacation."


            .Save
            .Close (olSave)
            End With
            'Release the AppointmentItem object variable.
            Set objAppt = Nothing
    End If

Open in new window


Thank you for your help.  I appreciate it.  
0
 
AronMcDAuthor Commented:
Thanks Chris.  I'll give it a shot once I get access to the public folder I need to update.  
0
 
AronMcDAuthor Commented:
That worked great Chris.  

Another situation came to my attention and I'm not sure how to go about addressing it.  There are times when an employee changes the dates on his/her vacation request.  Is there a way to search the calendar to see if said employee is already in the calendar and delete the previous entry in order to input the new entry?  Each request has a unique "RequestID" if that helps.

Thansk Chris!
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Each entry in the calendar has a unique entrid associated with it.  If when writing your appointments you grab the entryid, (objappt.entryid) and save it then you can directly access it for change purposes.  alternatively you can add your requestid to the item or search the calendar for the old details and then make the change.

Generally I would suggest you grab the entryid and save that in your database for the updates.

Chris
0
 
AronMcDAuthor Commented:
Ok I'm going to use objappt.entryid.  When adding a new entry I'll search for the entry id but how do I do that?  Do I use objappt.find?  
0
 
AronMcDAuthor Commented:
I'm using GetItemFromID.  I have to do some more testing but I think I got it.  Thank you so much for all of your help Chris.  
0
 
AronMcDAuthor Commented:
Chris should be awarded double the points IMO.  He actually helped me out with two different problems.
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Apologies, we had guests so i've been away from the pc but glad you have a solution for the outlook item id.

Chris
0
 
AronMcDAuthor Commented:
I'm not sure if I can still ask a question here of if I'm supposed to start a new thread...sorry I'm a newbie.  

The problem I'm having is when the vacation request is for multiple days...say 3/2/2011 to 3/7/2011.  It goes into the calendar but subtracts a day from the end date.  So in the calendar it shows the vaca as 3/2/2011 to 3/6/2011.  Is there a correct way to fix this?  
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Eitiquette calls for a new question ... but you can click the ask a related question button and that will keep a record of progress as it were.

Chris
0
 
AronMcDAuthor Commented:
Ok, I posted a new question.  Thanks Chris.
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Forgot to say, when you post a related question ALL the original involved experts get a notif.

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.