locked
microsoft outlook vcs/vcalendar problems RRS feed

  • Question

  • 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 event

    sStream.WriteLine("BEGIN:VCALENDAR");

    sStream.WriteLine("BEGIN:VEVENT");

    // Body of the Calendar event

    sStream.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 event

    sStream.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 user

    MemoryStream 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
    Wednesday, January 25, 2006 10:28 AM

All replies

  • User-1823088829 posted
    I had the same question, and with the exampple you wrote I could see the answer, and yes, you need to write '=0D=0A' at the end of your lines:

    objStringWriter.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Some text=0D=0AMore Text=0D=0AA new line=0D=0ALast Line=0D=0A");

    and this will return:
    Some text

    More Text
    A new line
    Last Line<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Hope this information helps.

    Wednesday, October 1, 2008 4:05 PM