Link to home
Start Free TrialLog in
Avatar of AronMcD
AronMcD

asked on

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!
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

please click the "request Attention" link and ask the the Outlook zone be added to this question.
Not sure about global / public mailboxes, but I did recently help with an Article : https://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.
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
Ignore the line dim fldr ... cut and paste error and didn't see it on my read through!

Chris
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"
Avatar of AronMcD
AronMcD

ASKER

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.  
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AronMcD

ASKER

Thanks Chris.  I'll give it a shot once I get access to the public folder I need to update.  
Avatar of AronMcD

ASKER

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!
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
Avatar of AronMcD

ASKER

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?  
Avatar of AronMcD

ASKER

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.  
Avatar of AronMcD

ASKER

Chris should be awarded double the points IMO.  He actually helped me out with two different problems.
Apologies, we had guests so i've been away from the pc but glad you have a solution for the outlook item id.

Chris
Avatar of AronMcD

ASKER

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?  
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
Avatar of AronMcD

ASKER

Ok, I posted a new question.  Thanks Chris.
Forgot to say, when you post a related question ALL the original involved experts get a notif.

Chris