Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to send/create a meeting request in the outlook calender on a button click. Also need to cancel/edit the same meeting details on another btn click event,.
Please help me in doing the same.Tried many possibilities but not working
Posted

1 solution

 
Share this answer
 
Comments
Member 11045379 28-Jan-15 7:00am    
Thankyou It worked within the same domain users.
But facing another issue. I want to send meeting outside the domain.But below exception is getting :
Mailbox unavailable. The server response was: 5.7.1 Unable to relay

Below is my code:

MailMessage msg = new MailMessage();
msg.From = new MailAddress("from@fromdomain.com");
msg.To.Add(new MailAddress("to@different.com"));

msg.Subject = "Training2";
msg.Body = "Test2";

StringBuilder str = new StringBuilder();
str.AppendLine("BEGIN:VCALENDAR");

//PRODID: identifier for the product that created the Calendar object
str.AppendLine("PRODID:-//ABC Company//Outlook MIMEDIR//EN");
str.AppendLine("VERSION:2.0");
str.AppendLine("X-WR-RELCALID:ABC2");
str.AppendLine("METHOD:REQUEST");

str.AppendLine("BEGIN:VEVENT");

str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime1));
str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.Now));
str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endTime1));
str.AppendLine(string.Format("LOCATION: {0}", "Location"));

id = Guid.NewGuid();
// UID should be unique.
str.AppendLine(string.Format("UID:{0}", id));
str.AppendLine(string.Format("SEQUENCE:{0}", 0));

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("STATUS:CONFIRMED");
//str.AppendLine("BEGIN:VALARM");
//str.AppendLine("TRIGGER:-PT15M");
//str.AppendLine("ACTION:Accept");
//str.AppendLine("DESCRIPTION:Reminder");
//str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY");
//str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");

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:VCALENDAR");
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
ct.Parameters.Add("method", "REQUEST");
ct.Parameters.Add("name", "meeting.ics");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
msg.AlternateViews.Add(avCal);
//Response.Write(str);
// sc.ServicePoint.MaxIdleTime = 2;
sc.Send(msg);

Please help.

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