/// <summary> /// Returns the ICalendar item /// </summary> /// <returns>a string output of the ICalendar item</returns> public virtual string GetICalendar() { Contract.Requires <NullReferenceException>(!string.IsNullOrEmpty(Description), "Description"); var FileOutput = new StringBuilder(); FileOutput.AppendLine("BEGIN:VCALENDAR") .AppendLineFormat("METHOD:{0}", Cancel ? "CANCEL" : "REQUEST") .AppendLine("PRODID:-//Craigs Utility Library//EN") .AppendLine("VERSION:2.0") .AppendLine("BEGIN:VEVENT") .AppendLine("CLASS:PUBLIC") .AppendLineFormat("DTSTAMP:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLineFormat("CREATED:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLine(StripHTML(Description.Replace("<br />", System.Environment.NewLine))) .AppendLineFormat("DTStart:{0}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLineFormat("DTEnd:{0}", CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLineFormat("LOCATION:{0}", Location) .AppendLineFormat("SUMMARY;LANGUAGE=en-us:{0}", Subject) .AppendLineFormat("UID:{0}{1}{2}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture), CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture), Subject); if (AttendeeList.Count > 0) { FileOutput.AppendLineFormat("ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{0}\":MAILTO:{0}", AttendeeList.ToString()); } if (Organizer != null) { FileOutput.AppendLineFormat("ACTION;RSVP=TRUE;CN=\"{0}\":MAILTO:{0}\r\nORGANIZER;CN=\"{1}\":mailto:{0}", Organizer.Address, Organizer.DisplayName); } if (ContainsHTML(Description)) { FileOutput.AppendLineFormat("X-ALT-DESC;FMTTYPE=text/html:{0}", Description.Replace("\n", "")); } else { FileOutput.AppendLineFormat("DESCRIPTION:{0}", Description); } return(FileOutput.AppendLine("SEQUENCE:1") .AppendLine("PRIORITY:5") .AppendLine("CLASS:") .AppendLineFormat("LAST-MODIFIED:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLine("STATUS:CONFIRMED") .AppendLine("TRANSP:OPAQUE") .AppendLineFormat("X-MICROSOFT-CDO-BUSYSTATUS:{0}", Status) .AppendLine("X-MICROSOFT-CDO-INSTTYPE:0") .AppendLine("X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY") .AppendLine("X-MICROSOFT-CDO-ALLDAYEVENT:FALSE") .AppendLine("X-MICROSOFT-CDO-IMPORTANCE:1") .AppendLine("X-MICROSOFT-CDO-OWNERAPPTID:-1") .AppendLineFormat("X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLineFormat("X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture)) .AppendLine("BEGIN:VALARM") .AppendLine("TRIGGER;RELATED=START:-PT00H15M00S") .AppendLine("ACTION:DISPLAY") .AppendLine("DESCRIPTION:Reminder") .AppendLine("END:VALARM") .AppendLine("END:VEVENT") .AppendLine("END:VCALENDAR") .ToString()); }
public virtual string GetVCalendar() { return(new StringBuilder().AppendLine("BEGIN:VCALENDAR") .AppendLine("VERSION:1.0") .AppendLine("BEGIN:VEVENT") .AppendLineFormat("DTStart:{0}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmss", CultureInfo.InvariantCulture)) .AppendLineFormat("DTEnd:{0}", CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmss", CultureInfo.InvariantCulture)) .AppendLineFormat("Location;ENCODING=QUOTED-PRINTABLE:{0}", Location) .AppendLineFormat("SUMMARY;ENCODING=QUOTED-PRINTABLE:{0}", Subject) .AppendLineFormat("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{0}", Description) .AppendLineFormat("UID:{0}{1}{2}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmss", CultureInfo.InvariantCulture), CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmss", CultureInfo.InvariantCulture), Subject) .AppendLine("PRIORITY:3") .AppendLine("End:VEVENT") .AppendLine("End:VCALENDAR") .ToString()); }