2016-01-06 129 views
0

我想創建一個使用C#Asp.net的Outlook預約ICS文件。以下是我從互聯網上獲得的示例代碼,但它缺少Subject和參與者。我怎樣才能在代碼中包含它?例如會議主題是:「財經會議」與會者是:[email protected][email protected][email protected]ics c#asp.net約會邀請

public string MakeHourEvent(string subject, string location, DateTime date, string startTime, string endTime) 
    { 
string filePath = string.Empty; 
string path = HttpContext.Current.Server.MapPath(@"\iCal\"); 
filePath = path + subject + ".ics"; 
writer = new StreamWriter(filePath); 
writer.WriteLine("BEGIN:VCALENDAR"); 
writer.WriteLine("VERSION:2.0"); 
writer.WriteLine("PRODID:-//hacksw/handcal//NONSGML v1.0//EN"); 
writer.WriteLine("BEGIN:VEVENT"); 
string startDateTime = GetFormatedDate(date)+"T"+GetFormattedTime(startTime); 
string endDateTime = GetFormatedDate(date) + "T" + GetFormattedTime(endTime); 
writer.WriteLine("DTSTART:" + startDateTime); 
writer.WriteLine("DTEND:" + endDateTime); 
writer.WriteLine("SUMMARY:" + subject); 
writer.WriteLine("LOCATION:" + location); 
writer.WriteLine("END:VEVENT"); 
writer.WriteLine("END:VCALENDAR"); 
writer.Close(); 
return filePath; 
} 
+0

是不是在您的代碼中的變量中指出的「主題」字段「摘要」? –

+1

使用可以爲您創建必要信息的庫,而不是自己重新創建它,您可能會好得多。看看[DDay.iCal](https://github.com/mdavid/DDay.iCal)。 – mason

回答

2

主題是在摘要:參數。描述:用於「身體」。

與會者使用ATTENDEE加入:屬性,即

ATTENDEE; CUTYPE =個人; ROLE = REQ-參與者; RSVP = TRUE; CN = 「約翰·史密斯」 ; X-NUM-客人= 0:的mailto :[email protected]

+0

謝謝彼得! – user3690095