csharp create ICS file extension

            
            string schLocation = "Conference Room 涂聚文约会你";
            string schSubject = "Business visit discussion约会";
            string schDescription = "Schedule description明天到深圳市福田區車公廟冶金大大廈約會";
            System.DateTime schBeginDate = Convert.ToDateTime("2/3/2012 10:00:00 PM");
            System.DateTime schEndDate = Convert.ToDateTime("2/3/2012 11:00:00 PM");

            
            String[] content = { "BEGIN:VCALENDAR",
                              "PRODID:-//Flo Inc.//FloSoft//EN",
                              "BEGIN:VEVENT",
                              "DTSTART:" + schBeginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"), 
                              "DTEND:" + schEndDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"), 
                              "LOCATION:" + schLocation, 
                                "PRIORITY:1",
                                 "SEQUENCE:0",
	                            "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + schDescription,
                              "SUMMARY:" + schSubject, "PRIORITY:3", 
                            "SEQUENCE:0",
	                     "END:VEVENT", "END:VCALENDAR" };
            String [] contents1={"BEGIN:VCALENDAR",
                "PRODID:-//XYZ Corp//My Product//EN",
                "VERSION:2.0",
                "CALSCALE:GREGORIAN",
                "METHOD:PUBLISH",
                "X-WR-CALNAME:My Calendar",
                "X-WR-TIMEZONE:(GMT-05:00) Eastern Time (US & Canada)",
                "BEGIN:VEVENT",
                "DTSTART:20061021T100000Z",
                "DTEND:20061021T130000Z",
                "DTSTAMP:20090211T175526Z",
                "UID:5f98dfd5-ac72-4ae1-b3c2-799a4e7c91f9",
                "CLASS:PUBLIC",
                "CREATED:20071104T183833Z",
                "DESCRIPTION: My description text.",
                "LAST-MODIFIED:20071104T183833Z",
                "LOCATION:涂聚文约会你 地址:123 Anywhere Street\\; Anyplace, NJ 12345\\; US",
                "SEQUENCE:0",
                "STATUS:CONFIRMED",
                "SUMMARY: My summary text.",
                "TRANSP:OPAQUE",
                "END:VEVENT",
                "BEGIN:VEVENT",
                "DTSTART:20061101T170000Z",
                "DTEND:20061101T180000Z",
                "DTSTAMP:20090211T175526Z",
                "UID:6eaef015-eb90-4e94-8e6c-0003b928969a",
                "CLASS:PUBLIC",
                "CREATED:20071104T183833Z",
                "DESCRIPTION: My description for number 2.",
                "LAST-MODIFIED:20071104T183833Z",
                "LOCATION: 涂聚文约会你 地址:123 Anywhere Street\\; Anyplace, NJ 12345\\; US",
                "SEQUENCE:0",
                "STATUS:CONFIRMED",
                "SUMMARY: My summary for #2.",
                "TRANSP:OPAQUE",
                "END:VEVENT",
                "END:VCALENDAR"
            };

            String [] contents2={
                "BEGIN:VCALENDAR",
                "PRODID:-//XYZ Corp//My Product//EN",
                "VERSION:2.0",
                "CALSCALE:GREGORIAN",
                "METHOD:PUBLISH",
                "X-WR-CALNAME:My Calendar",
                "X-WR-TIMEZONE:(GMT-05:00) Eastern Time (US & Canada)",
                "BEGIN:VEVENT",
                "DTSTART:20061021T100000Z",
                "DTEND:20061021T130000Z",
                "DTSTAMP:20090211T175526Z",
                "UID:5f98dfd5-ac72-4ae1-b3c2-799a4e7c91f9",
                "CLASS:PUBLIC",
                "CREATED:20071104T183833Z",
                "DESCRIPTION: My description text.",
                "LAST-MODIFIED:20110721T105554Z",
            "LOCATION:涂聚文约会你",
            "SEQUENCE:0",
            "STATUS:CONFIRMED",
            "SUMMARY:Insert something",
            "TRANSP:OPAQUE",
            "BEGIN:VALARM",
            "ACTION:DISPLAY",
            "DESCRIPTION:This is an event reminder",
            "TRIGGER:-P0DT0H10M0S",
            "END:VALARM",
            "END:VEVENT",
            "BEGIN:VEVENT",
            "DTSTART:20110909T083000Z",
            "DTEND:20110909T103000Z",
            "DTSTAMP:20110722T004312Z",
            "UID:[email protected]",
            "CREATED:20110721T105410Z",
            "DESCRIPTION:涂聚文明天到深圳市福田區車公廟冶金大廈約會",
            "LAST-MODIFIED:20110721T111008Z",
            "LOCATION:涂聚文约会",
            "SEQUENCE:1",
            "STATUS:CONFIRMED",
            "SUMMARY:Insert something",
            "TRANSP:OPAQUE",
            "BEGIN:VALARM",
            "ACTION:DISPLAY",
            "DESCRIPTION:Insert something",
            "TRIGGER:-P0DT0H10M0S",
            "END:VALARM",
            "END:VEVENT",
            "END:VCALENDAR"
            };

             String [] contents3={"BEGIN:VCALENDAR",
                    "PRODID:-//Google Inc//Google Calendar 70.9054//EN",
                    "VERSION:2.0",
                    "CALSCALE:GREGORIAN",
                    "METHOD:PUBLISH",
                    "X-WR-CALNAME:涂聚文约会你",
                    "X-WR-TIMEZONE:Insert something",
                    "X-WR-CALDESC:",
                    "BEGIN:VEVENT",
                    "DTSTART:20110909T180000Z",
                    "DTEND:20110909T200000Z",
                    "DTSTAMP:20110722T004312Z",
                    "UID:[email protected]",
                    "CREATED:20110721T105553Z",
                    "DESCRIPTION:",
                    "LAST-MODIFIED:20110721T105554Z",
                    "LOCATION:涂聚文约会你",
                    "SEQUENCE:0",
                    "STATUS:CONFIRMED",
                    "SUMMARY:Insert something",
                    "TRANSP:OPAQUE",
                    "BEGIN:VALARM",
                    "ACTION:DISPLAY",
                    "DESCRIPTION:This is an event reminder",
                    "TRIGGER:-P0DT0H10M0S",
                    "END:VALARM",
                    "END:VEVENT",

                    "BEGIN:VEVENT",
                    "DTSTART:20110909T083000Z",
                    "DTEND:20110909T103000Z",
                    "DTSTAMP:20110722T004312Z",
                    "UID:[email protected]",
                    "CREATED:20110721T105410Z",
                    "DESCRIPTION:",
                    "LAST-MODIFIED:20110721T111008Z",
                    "LOCATION:Auckland",
                    "SEQUENCE:1",
                    "STATUS:CONFIRMED",
                    "SUMMARY:涂聚文约会你",
                    "TRANSP:OPAQUE",
                    "BEGIN:VALARM",
                    "ACTION:DISPLAY",
                    "DESCRIPTION:Insert something",
                    "TRIGGER:-P0DT0H10M0S",
                    "END:VALARM",
                    "END:VEVENT",

                    "END:VCALENDAR"
             };

             String [] contents4={"BEGIN:VCALENDAR",
                "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN",
                "VERSION:2.0",
                "METHOD:PUBLISH",
                "X-CALSTART:20100611T140000Z",
                "X-CALEND:20100711T201500Z",
                "X-WR-RELCALID:{0000002E-5A22-AA75-713B-5C3715764495}",
                "X-WR-CALNAME: World Cup Football Complete Match Schedule 2010 South Africa",
                "BEGIN:VEVENT",
                "CATEGORIES:World Cup Football Complete Match Schedule 2010 South Africa",
                "CLASS:PUBLIC",
                "CREATED:20100608T231102Z",
                "DESCRIPTION:Group A\nFollow MarkThisDate on Twitter   markthisdate", 
                "DTEND:20100611T154500Z",
                "DTSTAMP:20100513T100200Z",
                "DTSTART:20100611T140000Z",
                "LAST-MODIFIED:20100608T231102Z",
                "LOCATION:涂聚文约会你",
                "PRIORITY:5",
                "SEQUENCE:0",
                "SUMMARY:涂聚文约会你 地址:涂聚文明天到深圳市福田區車公廟冶金大廈約會",
                "TRANSP:TRANSPARENT",
                "UID:[email protected]",
                "X-MICROSOFT-CDO-BUSYSTATUS:FREE",
                "X-MICROSOFT-CDO-IMPORTANCE:1",
                "END:VEVENT",
                "BEGIN:VEVENT",
                "CATEGORIES:涂聚文约会你 地址:涂聚文明天到深圳市福田區車公廟冶金大廈約會",
                "CLASS:PUBLIC",
                "CREATED:20100608T231102Z",
                "DESCRIPTION:天下为公",
                "DTEND:20100611T201500Z",
                "DTSTAMP:20100513T100200Z",
                "DTSTART:20100611T183000Z",
                "LAST-MODIFIED:20100608T231102Z",
                "LOCATION:Cape Town ",
                "PRIORITY:5",
                "SEQUENCE:0",
                 "SUMMARY:Uruguay - France",
                "TRANSP:TRANSPARENT",
                "UID:[email protected]",
                "X-MICROSOFT-CDO-BUSYSTATUS:FREE",
                "X-MICROSOFT-CDO-IMPORTANCE:1",
                "END:VEVENT",
                "BEGIN:VEVENT",
                "CATEGORIES:涂聚文约会你 地址:World Cup Football Complete Match Schedule 2010 South Africa",
                "CLASS:PUBLIC",
                "CREATED:20100608T231102Z",
                "DESCRIPTION:不作為的官都在步步高升",
                "DTEND:20100612T131500Z",
                "DTSTAMP:20100513T100200Z",
                "DTSTART:20100612T113000Z",
                "LAST-MODIFIED:20100608T231102Z",
                "LOCATION:不作為的官都在步步高升",
                "PRIORITY:5",
                "SEQUENCE:0",
                "SUMMARY:Korea Republic - Greece",
                "TRANSP:TRANSPARENT",
                "UID:[email protected]",
                "X-MICROSOFT-CDO-BUSYSTATUS:FREE",
                "X-MICROSOFT-CDO-IMPORTANCE:1",
                "END:VEVENT",
                "END:VCALENDAR"
                };

           String [] contents5={"BEGIN:VCALENDAR",
                "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN",
                "VERSION:2.0",
                "METHOD:PUBLISH",
                "X-MS-OLK-FORCEINSPECTOROPEN:TRUE",
                "BEGIN:VEVENT",
                "CLASS:PUBLIC",
                "CREATED:20120203T120222Z",
                "DESCRIPTION:Schedule description明天到深圳市福田區車公廟冶金大廈約會",
                "DTEND:20120203T150000Z",
                "DTSTAMP:20120203T120200Z",
                "DTSTART:20120203T140000Z",
                "LAST-MODIFIED:20120203T120222Z",
                "LOCATION:Conference Room 涂聚文约会你",
                "PRIORITY:1",//提醒时间
                "SEQUENCE:0",
                "SUMMARY:Business visit discussion约会",
                "TRANSP:OPAQUE",
                "UID:040000008200E00074C5B7101A82E00800000000B0D4B7BDAEE2CC01000000000000000010000000C05DF5EA2953C0499548F598C334C23C",
                "DESCRIPTION:X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2//EN"+
	                ">\n<HTML>\n<HEAD>\n<META NAME=Generator CONTENT=MS Exchange Server ve"+
	                "rsion 08.00.0681.000>\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f"+
	                "rom text/plain format -->\n\n<P>Schedule description明天到深圳市福"+
	                "田區車公廟冶金大大廈約會\n</P>\n\n</BODY>\n</HTML>",
                "X-MICROSOFT-CDO-BUSYSTATUS:BUSY",
                "X-MICROSOFT-CDO-IMPORTANCE:2",
                "BEGIN:VALARM",
                "TRIGGER:-PT1440M",
                "ACTION:DISPLAY",
                "DESCRIPTION:Reminder",
                "END:VALARM",
                "END:VEVENT",
                "END:VCALENDAR"};

            System.IO.File.WriteAllLines(Server.MapPath("Sample2.ics"), content,System.Text.Encoding.UTF8);
            System.IO.File.WriteAllLines(Server.MapPath("Sample3.ics"), contents1, System.Text.Encoding.UTF8);
            System.IO.File.WriteAllLines(Server.MapPath("Sample4.ics"), contents2, System.Text.Encoding.UTF8);
            System.IO.File.WriteAllLines(Server.MapPath("Sample5.ics"), contents3, System.Text.Encoding.UTF8);
            System.IO.File.WriteAllLines(Server.MapPath("Sample6.ics"), contents4, System.Text.Encoding.UTF8);
            System.IO.File.WriteAllLines(Server.MapPath("Sample7.ics"), contents5, System.Text.Encoding.UTF8);
            //METHOD TO SEND EMAIL IS CALLED
            SendMail();
            //Thread t1 = new System.Threading.Thread(new ThreadStart(SendMail));
            //t1.Start();

你可能感兴趣的:(create)