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!
Microsoft AccessMicrosoft ApplicationsOutlook

Avatar of undefined
Last Comment
Chris Bottomley

8/22/2022 - Mon
Jeffrey Coachman

please click the "request Attention" link and ask the the Outlook zone be added to this question.
Mark Wills

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.
Chris Bottomley

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Chris Bottomley

Ignore the line dim fldr ... cut and paste error and didn't see it on my read through!

Chris
conagraman

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"
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.  
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Chris Bottomley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AronMcD

ASKER
Thanks Chris.  I'll give it a shot once I get access to the public folder I need to update.  
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!
Chris Bottomley

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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
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?  
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.  
AronMcD

ASKER
Chris should be awarded double the points IMO.  He actually helped me out with two different problems.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Chris Bottomley

Apologies, we had guests so i've been away from the pc but glad you have a solution for the outlook item id.

Chris
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?  
Chris Bottomley

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
AronMcD

ASKER
Ok, I posted a new question.  Thanks Chris.
Chris Bottomley

Forgot to say, when you post a related question ALL the original involved experts get a notif.

Chris