Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having requirement to send the outlook meeting request. I did that & its working fine for single date. But the meeting should contains multiple dates. I am using Vcalendar please refer the following code .

Please give me ur suggestion

C#
SmtpClient sc = new SmtpClient();
  MailMessage msg = new MailMessage();
   StringBuilder str = new StringBuilder();
                  str.AppendLine("BEGIN:VCALENDAR");
                  str.AppendLine("VERSION:2.0");
                  str.AppendLine("METHOD:REQUEST");
                  str.AppendLine("BEGIN:VEVENT");
                  str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", DateTime.Now));
                  str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
                  str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddDays(1)));
                  str.AppendLine("LOCATION: India");
                  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("BEGIN:VALARM");
                  str.AppendLine("TRIGGER:-PT15M");
                  str.AppendLine("ACTION:DISPLAY");
                  str.AppendLine("DESCRIPTION:Reminder");
                  str.AppendLine("END:VALARM");
                  str.AppendLine("END:VEVENT");
                  str.AppendLine("END:VCALENDAR");
                  System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
                  ct.Parameters.Add("method", "REQUEST");
                  AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
                  msg.AlternateViews.Add(avCal);
                  sc.Send(msg);
Posted
Updated 20-Feb-14 22:50pm
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900