Normal Topic Send a Calendar/ICS Invite (Read 11375 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Send a Calendar/ICS Invite
Jan 22nd, 2018 at 7:43pm
Print Post Print Post  
Hey folks ... with the ineffable skills of Ray, I was able to build a Calendar email invite function in our sales database to handle timed calls!

Code
Select All
stat vFileName as string
stat vData as string
stat vSubject as string
stat vMessage as string
stat n as int
stat q as int

stat vStaffInfo as string
stat vDBID as string
stat vCallDate as date
stat vCallTime as time
stat vCallInvite as string
stat vContact as string
stat vTelephone as string

vStaffInfo = @xlookupsourcelist(@FN,@userid,"Staff Screen!StaffRef","staffname;staffemail")
vCallDate = @promptForUserInput("Scheduled Call Date?",CltNxt)
vCallTime = @PromptForuserinput("Scheduled Call Time?","09:00")
vCallInvite = @PromptForUserInput("Schedule For",@accessstringarray(vStaffInfo,2))
vContact = @PromptForUserInput("Person To Call",CltCt1)
vTelephone = @PromptForUserInput("Number To Call",CltTel1)

if vCallDate <> "" and vCallTime <> "" and vCallInvite <> ""
{
	vFileName = "S:\Data\RawData\" + CLTID + "-" + @num(@serverdate()) + "-" +@num(@servertime()) + ".ics"

	FileDelete(vFileName)
	q = FileOpen(vFileName)
	FileSeek(q,0)

	vData =
	"BEGIN:VCALENDAR" + @newline() +
	"PRODID:-//Lantica Corporation/Sesame 2.6.4/KDC-ICC/3.214//EN" + @newline() +
	"VERSION:2.0" + @newline() +
	// "METHOD:REQUEST" + @newline() +
	//"X-MS-OLK-FORCEINSPECTOROPEN:TRUE" + @newline() +

	"BEGIN:VTIMEZONE" + @newline() +
	"TZID:Eastern Standard Time" + @newline() +

	"BEGIN:STANDARD" + @newline() +
	"DTSTART:" + "16011104T020000" + @newline() +
	"RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11" + @newline() +
	"TZOFFSETFROM:-0400" + @newline() +
	"TZOFFSETTO:-0500" + @newline() +
	"END:STANDARD" + @newline() +

	"BEGIN:DAYLIGHT" + @newline() +
	"DTSTART:16010311T020000" + @newline() +
	"RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11" + @newline() +
	"TZOFFSETFROM:-0500" + @newline() +
	"TZOFFSETTO:-0400" + @newline() +
	"END:DAYLIGHT" + @newline() +

	"END:VTIMEZONE" + @newline() +

	"BEGIN:VEVENT" + @newline() +
	"ATTENDEE;CN=" + vCallInvite + ";RSVP=FALSE:mailto:" + vCallInvite + @newline() +
	"CLASS:PUBLIC" + @newline() +
	"CREATED:" +@num(@serverdate()) + "T" + @num(@servertime()) + "Z" + @newline() +
	"DESCRIPTION: \n\n" + @newline() +
	"DTEND;TZID=" + @chr(34) + "Eastern Standard Time" + @chr(34) + ":" + @num(vCallDate) + "T" + @sum(@num(vCallTime)+5) + "00" + @newline() +
	"DTSTAMP:" + @num(@serverdate()) + "T" + @num(@servertime()) +"Z" + @newline() +
	"DTSTART;TZID=" + @chr(34) + "Eastern Standard Time" + @chr(34) + ":" + @num(vCallDate) + "T" + @num(vCalltime) + "00" + @newline() +
	"LAST-MODIFIED:" + @num(@serverdate()) + "T" + @num(@servertime()) + "Z" + @newline() +
	"LOCATION:Sesame DR Screen" + @newline() +
	"ORGANIZER;CN=support@kingstondc.com:mailto:support@kingstondc.com" + @newline() +
	"PRIORITY:5" + @newline() +
	"SEQUENCE:0" + @newline() +
	"SUMMARY;LANGUAGE=en-ca:Call DBID 200662" + @newline() +
	"TRANSP:OPAQUE" + @newline() +

	"X-MICROSOFT-CDO-BUSYSTATUS:BUSY" + @newline() +
	"X-MICROSOFT-CDO-IMPORTANCE:1" + @newline() +
	"X-MICROSOFT-DISALLOW-COUNTER:FALSE" + @newline() +
	"X-MS-OLK-APPTSEQTIME:" + @num(@serverdate()) + "T" + @num(@servertime()) + "Z" + @newline() +
	"X-MS-OLK-AUTOFILLLOCATION:FALSE" + @newline() +
	"X-MS-OLK-CONFTYPE:0" + @newline() +

	"BEGIN:VALARM" + @newline() +
	"TRIGGER:-PT5M" + @newline() +
	"ACTION:DISPLAY" + @newline() +
	"DESCRIPTION:Reminder" + @newline() +
	"END:VALARM" + @newline() +
	"END:VEVENT" + @newline() +
	"END:VCALENDAR"

	FileWrite(q,vData)
	FileClose(q)

	// Writeln(vData)

	vSubject = "Scheduled Call For " + CltID + " -- " + CltName + " -- " + vTelephone + " -- " + vContact
	vMessage = "Calendar"

	n = @sendmail("mail.kingstondc.com",vSubject,@accessstringarray(vStaffInfo,2),vCallInvite,"","",vMessage,"bwettlaufer@kingstondc.com","SECRETPASSWORD",vFileName)
}
Else
{
	@msgbox("Can't Schedule Call","Without A Time and Date","Try Again")
}
 

  
Back to top
IP Logged