Today I will briefly discuss about how to create an ics file and send it to the client.
Step 1: Create the content of an .ics file.
string meetingLocation = "My Place.";
string meetingSubject = "31st Night party";
string meetingDescription = "Celebration of new year.";
System.DateTime meetingBeginDate = Convert.ToDateTime("31/12/2011 10:00:00 PM");
System.DateTime meetingEndDate = Convert.ToDateTime("1/1/2012 11:00:00 AM");
String[] contents = { "BEGIN:VCALENDAR", "PRODID:-//Flo Inc.//FloSoft//EN",
"BEGIN:VEVENT","DTSTART:"
+ meetingBeginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),"DTEND:"
+ meetingEndDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"), "LOCATION:"
+ meetingLocation, "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + meetingDescription,
"SUMMARY:" + meetingSubject, "PRIORITY:3", "END:VEVENT", "END:VCALENDAR" };
Step 2: Save it to server machine[could be in temp document folder] as an ics file.
System.IO.File.WriteAllLines(Server.MapPath("test.ics"), contents);
Step 3: Attach the file into email as an email attachment.
Attachment mailAttachment = new Attachment(Server.MapPath("test.ics"));
yourMailMessage.Attachments.Add(mailAttachment);Where yourMailMessage is an instance object of type System.Net.Mail.MailMessage .
Now if the mail is sent ,the receiver will get an appointment file as an attachment and just by double clicking on that attached file user can add meeting to his outlook client.
No comments:
Post a Comment