User1243045096 posted
hi guys,
Need some help here, heres code snippet to save in the vcs format,
public static MemoryStream SaveToVCSFormat(){
MemoryStream mStream = new MemoryStream();StreamWriter sStream = new StreamWriter(mStream);sStream.AutoFlush =
true;// Header of the Calendar eventsStream.WriteLine(
"BEGIN:VCALENDAR");sStream.WriteLine(
"BEGIN:VEVENT");// Body of the Calendar eventsStream.WriteLine(
"DTSTART:" + _startDate.ToString("yyyyMMdd\\THHmmss\\Z"));sStream.WriteLine(
"DTEND:" + _endDate.ToString("yyyyMMdd\\THHmmss\\Z"));sStream.WriteLine(
"LOCATION:" + _location);sStream.WriteLine(
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + _description);sStream.WriteLine(
"SUMMARY:" + _subject);// Footer of Calendar eventsStream.WriteLine(
"PRIORITY:3");sStream.WriteLine(
"END:VEVENT");sStream.WriteLine(
"END:VCALENDAR");return mStream;}
& the piece that sends it to the user
// Send it to the userMemoryStream CalendarItem = TCalendar.SaveToVCSFormat();Response.Clear();
Response.ContentType =
"text / x - vCalendar";Response.AppendHeader(
"Content-Disposition", "attachment; filename=AddInteraction.vcs");Response.AppendHeader(
"Content-Length", CalendarItem.Length.ToString());Response.BinaryWrite(CalendarItem.ToArray());
Response.End();
Now ..
This works perfectly as long as the
_description string is only one line. For multple lines , string = "tralalal\rtralalallaaa", Outlook won't open the created vcs file. Throws a error.
Next ...
If I create an Calendar event in Outlook -> Save As -> Open with Notepad it looks like this
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:1.0
BEGIN:VEVENT
DTSTART:20060125T060000Z
DTEND:20060125T063000Z
LOCATION;ENCODING=QUOTED-PRINTABLE:test area
UID:040000008200E00074C5B7101A82E0080000000070AD630FD121C6010000000000000000100
00000CA988CCE64F06D43AE4896ED52F782B5
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Line 1=0D=0ALine 2=0D=0ALine 3=0D=0AL=
ine 4=0D=0A
SUMMARY;ENCODING=QUOTED-PRINTABLE:testing
PRIORITY:3
END:VEVENT
END:VCALENDAR
its has alot off " =0D=0A " characters for each new line @ Description. i think?
when I create it with the aboved code , it does not have these "=0D=0A" (new line ) characters. like below ..
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20060125T151200Z
DTEND:20060208T151200Z
LOCATION:1
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:1aaaa
aaaa
SUMMARY:1
PRIORITY:3
END:VEVENT
END:VCALENDAR
what am I missing ? how do I create this properly, someone point me into the right direction please :P
thanks