Adding a button with action "Add to Calendar"

Hi…hoping someone can guide me on this one. I have a training notice with a button to “reply to express your interest”. This is working fine but I would also like this same button to add this event to the recipients calendar. I have searched but come up empty. Thought there would be a button action titled “add to calendar” but that seems too easy! Thanks in advance…

Subject: Adding a button with action “Add to Calendar”

Here is probably more code than you need, will try to clean it up, basically we have a vacation request, where it takes those days and adds it to the calendar, if this is one day training or multi day training, this should work. Originator is the name of the person who’s calendar we are getting. This is creating a full day event if a full day vacation or an appointment if a half day event.

Set nam = New NotesName(doc.GetItemValue(“Originator”)(0))

	strname = nam.Common

	Set personlookupview = dbnab.GetView("(ByListName)")

	Set persondoc = personlookupview.GetDocumentByKey(strName)

	If persondoc Is Nothing Then

		'Send an email to greg saying there isn't a person document for this person

	End If

	strServer = persondoc.MailServer(0)

	strDBNAme = persondoc.MailFile(0)

	If Right(strDBName,3) = "nsf" Then

	Else

		strDBName = strDBName+".nsf"

	End If

	If doc.HalfDay(0) = "Half Day" Then

		strStartTime = doc.StartTime(0)

		strEndTime = doc.EndTime(0)

		doc.EndDate = doc.StartDate

		strAppointmentType = "0"

	Else

		strStartTime = "04:00:00 AM"

		strEndTime = "08:00:00 PM"

		strAppointmentType = "2"

	End If

	Set maildb = s.GetDatabase(strServer,strDBName)

	Set maildoc = New NotesDocument( maildb )

	maildoc.From = s.UserName

	maildoc.~$Alarm = 1

	maildoc.~$AlarmOffset = -1440

	maildoc.~$LangPrincipal = ""

	maildoc.~$AltPrincipal = s.UserName

	maildoc.~$BusyName = doc.Originator(0)

	maildoc.~$BusyPriority = "1"

	maildoc.~$CSVersion = 2

	maildoc.~$PublicAccess="1"

	maildoc.~$UpdatedBy = doc.Originator(0)

	maildoc.~$SMTPKeepNotesItems = 1

	maildoc.~$HFFlags = 1

	maildoc.~$ExpandGroups =3

	maildoc.Logo=  "StdNotesLtr39"

	maildoc.SaveOptions= ""

	maildoc.MailOptions=""

	maildoc.~$FromPreferredLanguage = "en-US"

	maildoc.OnlinePlace = ""

	maildoc.~$LangChair =""

	maildoc.Alarms =1

	maildoc.OrgConfidential = ""

	maildoc.StartTimeZone = "Z=5$DO=0$ZX=66$ZN=US Eastern"

	maildoc.EndTimeZone = "Z=5$DO=0$ZX=66$ZN=US Eastern"

	maildoc.Repeats = ""

	maildoc.OrganizerInclude = ""

	maildoc.Location = ""

	maildoc.RoomToReserve =""

	maildoc.Resources = ""

	maildoc.OnlineMeeting=""

	maildoc.Presenters = ""

	maildoc.OnlinePlaceToReserve = ""

	maildoc.AudioVideoFlags = ""

	maildoc.SendAttachments = ""

	maildoc.SchedulerSwitcher = 1

	maildoc.~$BorderColor = "D2DCDC"

	maildoc.BookFreeTime = ""

	maildoc.EnterSendTo = ""

	maildoc.EnterCopyTo = ""

	maildoc.EnterBlindCopyTo = ""

	

	maildoc.Notes = ""

	maildoc.Alarms =""

	maildoc.ExcludeFromView = "D"

	maildoc.SequenceNum = 1

	maildoc.UpdateSeq = 1

	maildoc.AltChair = doc.Originator(0)

	maildoc.WebDateTimeInit = 1

	maildoc.ApptUNID = doc.UniversalID

	maildoc.Categories = doc.ReqType

	maildoc.Chair = doc.Originator

	

	maildoc.MeetingType = 1

	maildoc.Principal = doc.Originator

	maildoc.~_viewicon = 139

	maildoc.Subject =  "Time-Off Request: "+ doc.ReqType(0) 

	Set tmpRTItem = New NotesRichTextItem(MailDoc, "Body")

	tmpRTItem.AppendText "Please note, do not delete this document to cancel your time off request. If you need to reschedule or cancel this request, please click the following link:"

	tmpRTItem.AppendText Chr$(13)+Chr$(13)

	tmpRTItem.AppendDocLink doc, "Link to Time Off Request"

	maildoc.Form = "Appointment"

	maildoc.AppointmentType  = strAppointmentType

	Set StartItem = doc.GetFirstItem( "StartDate" )	

	Set EndItem = doc.GetFirstItem( "EndDate" )

	Set dtStartDate = Startitem.DateTimeValue

	Set dtEndDate = Enditem.DateTimeValue	

	z = 0

	While dtStartDate.DateOnly <= dtEndDate.DateOnly

		Set enddatetime = New NotesDateTime( doc.EndDate(0) + " 07:00:00 AM" )

		strMatch = "N"

		If doc.ExcludeWeekends(0) =  "Yes" Then

			For x = 0 To Ubound(doc.DaysofTheWeek)

				If Weekday(dtStartDate.DateOnly)=doc.DaysofTheWeek(x) Then

			'Match, do not create the vacation for that day

					strMatch = "Y"			

				End If

			Next

		End If

		If strMatch = "N" Then

			Redim Preserve datecalendar(z)

			datecalendar(z) = Cdat(dtStartDate.DateOnly + " " + strStartTime)

			z=z+1

		End If 					

		Call dtStartDate.AdjustDay(1)	

	Wend			

	Dim calendardatetimeitem As New notesitem(maildoc, "CalendarDateTime", datecalendar) 

	calendardatetimeitem.isSummary=True 

	Dim calendardatetimeitem2 As New notesitem(doc, "CalendarDateTime", datecalendar) 

	calendardatetimeitem2.isSummary=True 

	

	Set calendardatetime = New NotesDateTime( Cdat(doc.EndDate(0) + " "+ strEndTime) )

	Dim item1 As New notesitem(maildoc, "AppendEndTime", calendardatetime.TimeOnly) 

	item1.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.StartDate(0)+ " " + strStartTime) )

	Dim item2 As New notesitem(maildoc, "AppendStartTime", calendardatetime.TimeOnly) 

	item2.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.EndDate(0)) )

	Dim item4 As New notesitem(maildoc, "EndDate", calendardatetime.DateOnly) 

	item4.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.EndDate(0)+ " "+ strEndTime) )

	Dim item5 As New notesitem(maildoc, "EndDateTime", calendardateTime) 

	item5.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.EndDate(0) + " "+ strEndTime) )

	Dim item6 As New notesitem(maildoc, "EndTime", calendardatetime.TimeOnly) 

	item6.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.StartDate(0)))

	Dim item7 As New notesitem(maildoc, "StartDate", calendardatetime.DateOnly) 

	item7.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.StartDate(0)+ " " + strStartTime) )

	Dim item8 As New notesitem(maildoc, "StartDateTime", calendardatetime) 

	item8.isSummary=True 

	Set calendardatetime = New NotesDateTime( Cdat(doc.StartDate(0)+ " " + strStartTime ))

	Dim item9 As New notesitem(maildoc, "StartTime", calendardatetime.TimeOnly) 

	item9.isSummary=True 

	

	If doc.HalfDay(0) = "Half Day" Then

		doc.TotalNoOfDays = ".5"

	Else

		doc.TotalNoofDays = Cstr(z)

	End If

	Call maildoc.Save( True, True )