Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Using C# to create a calendar entry that will look native to Office 365 OWA

$
0
0

I've been through a whole lot of sample code and it seems like I can't get a C# program using the standard SmtpClient classes to be able to create a meeting invitation with an embedded VCALENDAR request to show up as anything but a .ICS file attachment.  The following code does send a valid ICS file, but there is no way to use it using Outlook Web Access...  Any ideas short of using the Microsoft Office Interop classes?

SmtpClient sc = new SmtpClient("");
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("cirwin@besl.com", "Chris Irwin");
            msg.To.Add(new MailAddress("coi@cirwin.com", "Chris Irwin"));
            msg.To.Add(new MailAddress("cirwin01@gmail.com", "Chris Irwin"));
            msg.Subject = "Send Calendar Appointment Email";
            msg.Body = "Here is the Body Content";
            StringBuilder str = new StringBuilder();
            str.AppendLine("BEGIN:VCALENDAR");
            str.AppendLine("PRODID:-//Ahmed Abu Dagga Blog");
            str.AppendLine("VERSION:2.0");
            str.AppendLine("METHOD:REQUEST");
            str.AppendLine("BEGIN:VEVENT");
            str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime));
            str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
            str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endTime));
            str.AppendLine("LOCATION: Dubai");
            str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
            str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));
            str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));
            str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));
            str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));
            str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));
            str.AppendLine("END:VEVENT");
            str.AppendLine("END:VCALENDAR");
            System.Net.Mime.ContentType typeC = new System.Net.Mime.ContentType("text/calendar");
            typeC.Parameters.Add("method", "REQUEST");
            typeC.Parameters.Add("name", "meeting.ics");
            AlternateView m_calV = AlternateView.CreateAlternateViewFromString(str.ToString(), typeC);
            msg.AlternateViews.Add(m_calV);
            sc.Send(msg);


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>