Solved

Linking to Outlook Calander from Access

Posted on 2011-03-07
20
453 Views
Last Modified: 2013-11-27
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!
0
Comment
Question by:AronMcD
20 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35060881
please click the "request Attention" link and ask the the Outlook zone be added to this question.
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 35079663
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35079817
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35079819
Ignore the line dim fldr ... cut and paste error and didn't see it on my read through!

Chris
0
 
LVL 10

Expert Comment

by:conagraman
ID: 35082440
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
 

Author Comment

by:AronMcD
ID: 35082708
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
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 35082806
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
 

Author Comment

by:AronMcD
ID: 35082882
Thanks Chris.  I'll give it a shot once I get access to the public folder I need to update.  
0
 

Author Comment

by:AronMcD
ID: 35096808
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35097473
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
 

Author Comment

by:AronMcD
ID: 35098681
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
 

Author Comment

by:AronMcD
ID: 35099259
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
 

Author Closing Comment

by:AronMcD
ID: 35099270
Chris should be awarded double the points IMO.  He actually helped me out with two different problems.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35099973
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
 

Author Comment

by:AronMcD
ID: 35108488
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35109516
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
 

Author Comment

by:AronMcD
ID: 35109613
Ok, I posted a new question.  Thanks Chris.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35110123
Forgot to say, when you post a related question ALL the original involved experts get a notif.

Chris
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

706 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now