Export SharePoint Event To Outlook
By Alon Havivi
Exporting events from SharePoint to Outlook
Here is a small web part that render a drop down list with calendar events and a
button to export the selected event to outlook
SPList list = SPContext.Current.Web.Lists["Calendar"];
SPListItem item = list.GetItemById(Convert.ToInt32(ddlEvents.SelectedValue));
string location = item["Location"] as string;
string subject = item.Title;
string description = item["Description"] as string;
DateTime beginDate = (DateTime)item["Start Time"];
string beginDateString = beginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");
DateTime endDate = (DateTime)item["End Time"];
string endDateString = endDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z");
string[] contents = {"BEGIN:VCALENDAR",
"PRODID:-//My company//My product//EN",
"BEGIN:VEVENT",
"DTSTART:" + beginDateString,
"DTEND:" + endDateString,
"LOCATION:" + location,
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + description,
"SUMMARY:" + subject, "PRIORITY:3",
"END:VEVENT",
"END:VCALENDAR" };
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ContentType = "text/calendar";
response.AddHeader("Content-disposition", "attachment;filename=event" + ddlEvents.SelectedValue + ".ics");
response.Write(string.Join("\r\n", contents));
response.Write(contents);
response.Flush();

Download the webpart
Export SharePoint Event To Outlook (1213 Views)