Creating an appointment in outlook shared calendar using an access form (1 Viewer)

darbid

Registered User.
Local time
Today, 15:52
Joined
Jun 26, 2008
Messages
1,428
Therefore I would like to say a big THANK YOU :).
Your Welcome.
However I have one question that has not been covered here. I wish to check the slot before adding the appointment i.e. I wish to check whether the slot is busy or free and if busy check the type of category used.

i have never done what you are talking about as I always send the appointment item and then let the person decide whether to accept or not.

But I had a look at the Appointment object.
http://msdn.microsoft.com/en-gb/library/aa210899(office.11).aspx

I like the http://msdn.microsoft.com/en-gb/library/aa211808(office.11).aspx conflicts collection which has a little example there. You can then get a conflict object and check it. I am not sure if this is only going to show the conflicts of outlook on the computer this code is working or on all conflicts.

Another way is to use your email addresses to get a Recipient and then use the freebusy method. http://msdn.microsoft.com/en-gb/library/aa220097(office.11).aspx
 

bsnwyase

New member
Local time
Today, 06:52
Joined
Nov 26, 2012
Messages
4
Thanks i wil have a look at the conflicts item, hopefully i can check the type of conflict i.e. category selected (all calendar entries have a category assigned, makes it easier to know the type of slot by colour). I have already come across the free/busy method but this just returns some zeros and ones which I didn't know what to do with. I am also confused on when checking the calendar how I can set the range, allot of examples just show the actual code nothing more.

Thanks again for your time.
 

darbid

Registered User.
Local time
Today, 15:52
Joined
Jun 26, 2008
Messages
1,428
I see the free busy method is a little different. Write some code. Show me what you get and I will help you. Remember, just because you are coding it does not mean you will get to see any more details about other peoples calendars than what you can see from your own outlook client. unless of course the calendar is share.
 

bsnwyase

New member
Local time
Today, 06:52
Joined
Nov 26, 2012
Messages
4
Hi darbid,

After all day today I have finally solved on how i can do this. The code is below:

'Extract date and time from form
endtime = DateAdd("n", Me!hrs, Me!sstarttime)
mystart = Format(Me!startdate, "mm/dd/yyyy") & " " & Format(Me!sstarttime, "Medium Time")
myEnd = Format(Me!startdate, "mm/dd/yyyy") & " " & Format(endtime, "Medium Time")

'Construct date range filter and include appintment that overlap
strRestriction = "[Start] <= '" & myEnd _
& "' AND [End] >= '" & mystart & "'"

'set up items from shared folder
Set oItems = objFolder.Items

'Including recurrent appointments requires sorting by the Start property
oItems.IncludeRecurrences = True
oItems.Sort "[Start]"

'Restrict the Items collection for the date range
Set oItemsInDateRange = oItems.Restrict(strRestriction)

'item results
For Each objAppt2 In oItemsInDateRange
If objAppt2.Categories = "Other" Then GoTo ExitProc
Next

'if the Categories does not equal other than i simply just run through the add item code. Hopefully this will help someone who needs to check the calendar first.
 

bsnwyase

New member
Local time
Today, 06:52
Joined
Nov 26, 2012
Messages
4
I did try the free/busy method which returned the zero and 1's which then you have to do more calculations on which hour you had to check but in my case this was just too complicated and if it returned a 1 then i was not able to read the properties of that 1. The method I used allowed me to check the slot if it was busy check the type of appointment.

Again thanks for your time for the links provided.
 

chris1976

New member
Local time
Today, 20:52
Joined
Feb 21, 2017
Messages
9
Hi can anyone help me please

i want to put appoitments on my sharepoint calender, i have copied the above code but it just coming up with this appointment has already added to outlook but when i check outlook nothing as been added,

tryied askin MS there want a whopping 499USD to help me:eek:
 

darbid

Registered User.
Local time
Today, 15:52
Joined
Jun 26, 2008
Messages
1,428
I dont know sharepoint at all, but show your code and lets see if we can work it out.
 

chris1976

New member
Local time
Today, 20:52
Joined
Feb 21, 2017
Messages
9
thank you so much. here is the code:
Private Sub AddAppt_Click()
On Error GoTo AddAppt_Err
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
Exit Sub
' Add a new appointment.
Else
Dim outobj As outlook.Application
Dim outappt As outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set utappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = _
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
 

darbid

Registered User.
Local time
Today, 15:52
Joined
Jun 26, 2008
Messages
1,428
Ok great. That code is a copy of the code about 4 pages back, so now read my comments on that code to improve it.

Next is your sharepoint calendar shared with Outlook. If yes you will need to get that calendar, if no I think you can only access it view http calls.

http://www.outlookcode.com/codedetail.aspx?id=1836 see this link for getting a share point shared folder.
 

chris1976

New member
Local time
Today, 20:52
Joined
Feb 21, 2017
Messages
9
yes it is share with outlook but 1st i need to get this right

here my code now:
Private Sub AddAppt_Click()
Dim objNS As outlook.NameSpace
Dim objFolder As outlook.MAPIFolder 'get name of other persons folder
Dim objRecip As outlook.Recipient 'other persons name
Dim strName As String 'the name or email of the persons folder
Dim objAppt As outlook.AppointmentItem
Dim objApp As outlook.Application
Dim outobj As outlook.Application
Set outobj = CreateObject("outlook.application")

'On Error Resume Next
' ### name of person whose Calendar you want to use ###
'This example assume that the Outlook object is already alive.
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objRecip = objNS.CreateRecipient(strName) - objRecip = "" - strName = "richieatchrisdpv.onmicrosoft com"
If Not objRecip.Resolve Then
MsgBox "We have a problem"
End If
strName = Me.Text28
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
objRecip = "" - olFlowderCalendar = 9
If Not objFolder Is Nothing Then
Set objAppt = objFolder.Items.Add
If objAppt Is Nothing Then
Set objAppt = objApp.CreateItem(olAppointmentItem)
End If

End If
With objAppt
strName = Me.Text28
.Start = Me!ApptDateFrom
.End = Me!ApptDateTo
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = _
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
.BusyStatus = olOutOfOffice
End If
.Save
End With



i not understand the "strName =Me.Text"

the domain is chrisdpv.onmicrosoft.com
user at chrisdpv.onmicrosoft com

i haven't done the code for sharepoint yet because there some errors in this code and i can't work it out i have looked at your pass message but i still don't know what ive done wrong
 

darbid

Registered User.
Local time
Today, 15:52
Joined
Jun 26, 2008
Messages
1,428
If the calendar is actually shared with Outlook then you need to get the right calendar first. See the link I posted as to how to do that.

Also can you please use the CODE button for your code so that it is easier to read.
 

Users who are viewing this thread

Top Bottom