2011-12-30 16 views
2

我需要一個通過電子郵件將活動添加到我的日曆的示例。例如,當我向我的客戶發送關於他們的約會的電子郵件時,我希望他們在電子郵件中有一個選項,這將允許他們通過單擊按鈕或其他東西在其日曆上添加事件。通過電子郵件通知向您的日曆添加約會

有什麼東西可以讓別人指引我嗎?

我需要這主要與ColdFusion的9

謝謝使用!

+2

調查ICS。這是一個相當簡單的格式,可以與大多數現代日曆無縫協作。 (我爲內部網做了類似的事情,以方便人們將事件添加到他們的Outlook日曆中。不幸的是,我沒有任何我的代碼可以使用。) – ale 2011-12-30 19:19:00

+0

@AlEverett感謝您的信息,我會仔細研究它。 – Geo 2011-12-30 19:25:54

回答

2

我從http://www.cflib.org/udf/icalus

WebDH提供了一個很好的例子here推薦iCalUs UDF。

下面是一個使用CF9的例子,我很快把它們放在一起,但還沒有測試過。

<cfscript> 

    eventStr = {}; 
    eventStr.organizerName = "John Doe"; //Organizer Name 
    eventStr.organizerEmail = "[email protected]"; //Organizer Email 
    eventStr.startTime = ParseDateTime("12/30/2011 11:00"); //format: m/d/yyyy HH:mm OR h:mm TT -- this is Eastern time 
    eventStr.subject = "Demo Example"; 
    eventStr.location = "StackOverflow.com"; 
    eventStr.description = "Example iCalendar using CF9"; 

    // Display in browser 
    //pc = getpagecontext().getresponse(); 
    //pc.getresponse().setcontenttype('text/calendar'); 
    //pc.setHeader("Content-Disposition","inline;filename=newAppointment.ics"); 
    //writeOutput(iCalUS(eventStr)); 

    //Email 
    m = new mail(); 
    m.setSubject("Event"); 
    m.setTo("[email protected]"); 
    m.setFrom("[email protected]"); 
    m.setServer("localhost"); 
    //m.addParam(file="#ACCOUNT_TXT_FILE#"); 
    m.addPart(type="text", charset="utf-8", wraptext="72", body="Attached is a calendar event..."); 
    m.addPart(type="text/calendar" body="#iCalUS(eventStr)#"); 
    m.send(); 

</cfscript> 

再舉一例reference演示瞭如何通過電子郵件發送的日曆事件。

+0

感謝您的幫助,我正在爲此而努力。這看起來並不是一件很難的事情。我只需花時間用我公司每天發送的各種電子郵件進行測試 – Geo 2011-12-30 19:55:39

+0

我做到了。再次感謝! – Geo 2011-12-30 22:41:12

1

這是一個非常基本的ICS格式實現。這是設計用來通過瀏覽器訪問的,但通過改變ICS擴展名創建文本文件並通過電子郵件發送它是相當學術化的。

<cfheader name="Content-Disposition" value="attachment; filename=event.ics" /> 
<cfcontent reset="true" type="text/calendar" /> 
<cfscript> 
// handle all-day events 
if (NOT isDate(starttime) OR NOT isDate(endtime)) { 
    dtstart=';VALUE=DATE:#dateFormat(eventdate,"yyyymmdd")#'; 
    dtend=';VALUE=DATE:#dateFormat(dateAdd("d",1,eventdate),"yyyymmdd")#'; 
} else { 
    dtstart=';TZID="Eastern Standard Time":#dateFormat(eventdate,"yyyymmdd")#T#timeFormat(starttime,"HHmmss")#'; 
    dtend=';TZID="Eastern Standard Time":#dateFormat(eventdate,"yyyymmdd")#T#timeFormat(endtime,"HHmmss")#'; 
} 
</cfscript> 

<cfoutput> 
BEGIN:VCALENDAR 
PRODID:-//Company//Source//EN 
VERSION:2.0 
METHOD:PUBLISH 
BEGIN:VTIMEZONE 
TZID:Eastern Standard Time 
BEGIN:STANDARD 
DTSTART:16011104T020000 
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11 
TZOFFSETFROM:-0400 
TZOFFSETTO:-0500 
END:STANDARD 
BEGIN:DAYLIGHT 
DTSTART:16010311T020000 
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3 
TZOFFSETFROM:-0500 
TZOFFSETTO:-0400 
END:DAYLIGHT 
END:VTIMEZONE 
BEGIN:VEVENT 
CLASS:PUBLIC 
CREATED:#dateFormat(dateAdded,"yyyymmdd")#T#timeFormat(dateAdded,"HHmmss")#Z 
DESCRIPTION:#desc# 
DTEND#dtend# 
DTSTAMP:#dateFormat(dateAdded,"yyyymmdd")#T#timeFormat(dateAdded,"HHmmss")#Z 
DTSTART#dtstart# 
LAST-MODIFIED:#dateFormat(dateApproved,"yyyymmdd")#T#timeFormat(dateApproved,"HHmmss")#Z 
LOCATION:#location# 
PRIORITY:5 
SEQUENCE:0 
SUMMARY;LANGUAGE=en-us:#title# 
TRANSP:OPAQUE 
UID:#dateFormat(now(),"yyyymmdd")#T#timeFormat(now(),"HHmmss")#[email protected]#uniqueID# 
BEGIN:VALARM 
TRIGGER:-PT15M 
ACTION:DISPLAY 
DESCRIPTION:Reminder 
END:VALARM 
END:VEVENT 
END:VCALENDAR 
</cfoutput>