Calendar invite using Jmail

173 Views Asked by At

Could someone provide me with a full/working example of a snippet/function (PHP or Classic ASP) that sends a meeting invite (compatible with Outlook) using JMail?

1

There are 1 best solutions below

3
Dijkgraaf On BEST ANSWER

Here is the function I created for my solution in Classic ASP for creating a calendar file.

You will have to customize it. e.g. the fmtDateTime & FmtDate are custom functions to format the date. You will need to use your own functions for that. Also I had some things hard coded (e.g. NAME OF SENDING APPLICATION, SENDER NAME & SENDER EMAIL) but you can make those parameters easily enough. And you will want to set the appropriate time zone as well.

Function WriteICSFile(CalendarFileName,startdate,enddate,starttime,endtime,description,summary,venue)

    If enddate = "" Then enddate = startdate

    startdate = startdate & " " & starttime
    enddate = enddate & " " & endtime
    txtNow = fmtDateTime(now(),"yyyy-mm-dd hh:mm:ss")
    txtNow = Replace(Replace(Replace(txtNow,"-","")," ","T"),":","")

    txtStartDate=FmtDate(startdate,"%Y%M%DT%H%N00") 
    txtEndDate=FmtDate(enddate,"%Y%M%DT%H%N00")

    Contents = "BEGIN:VCALENDAR" & vbCRLF &_
        "VERSION:2.0" & vbCRLF &_
        "PRODID:-//NAME OF SENDING APPLICATION//EN" & vbCRLF &_
        "BEGIN:VEVENT" & vbCRLF &_
        "UID:Event" & intEvents & vbCRLF &_
        "DTSTAMP;TZID=Pacific/Auckland:" & txtNow & vbCRLF &_
        "ORGANIZER;CN=SENDER NAME:MAILTO:SENDER EMAIL" & vbCRLF &_
        "DTSTART;TZID=Pacific/Auckland:" & txtStartDate & vbCRLF &_
        "DTEND;TZID=Pacific/Auckland:" & txtEndDate & vbCRLF &_
        "DESCRIPTION:" & description & vbCRLF &_
        "SUMMARY:" & summary & vbCRLF &_
        "LOCATION:" & venue & vbCRLF &_
        "END:VEVENT" & vbCRLF &_
        "END:VCALENDAR"  & vbCRLF


        set oFs = server.createobject("Scripting.FileSystemObject")
        set oTextFile = oFs.OpenTextFile(CalendarFileName, 2, True)
        oTextFile.Write Contents
        oTextFile.Close
        set oTextFile = nothing
        set oFS = nothing       
End Function