Click here to Skip to main content
15,849,829 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hi All,

My code is working fine to send Appointment.but the invitee couldn't accept the Meeting appointment.The options Accept/Tectative/Decline shows Inactive.

Any one guide me to active Accept/Tectative/Decline option.
C#
private void SendAppointment(string subject,string To,DateTime Start,DateTime End)
       {
           try
           {
               DateTime dtNow = DateTime.Now;
               MailMessage msg = new MailMessage();
               msg.From = new MailAddress("vinoth.palanivelu@daimler.com");
               msg.To.Add(To); ;
               msg.Subject = subject;
               msg.Body = "Here is the Body Content";
               msg.IsBodyHtml = true;
               StringBuilder str = new StringBuilder();
               str.AppendLine("BEGIN:VCALENDAR");
               str.AppendLine("PRODID:-//Schedule a Meeting");
               str.AppendLine("VERSION:2.0");
               str.AppendLine("METHOD:REQUEST");
               str.AppendLine("BEGIN:VEVENT");
               str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", Start.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
               str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", (End - Start).Minutes.ToString()));
               str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", End.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z")));
               str.AppendLine("LOCATION: TBD");
              // 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.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();
               smtpclient.Host = "53.151.100.102";
               smtpclient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
               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);
               smtpclient.Send(msg);
           }
           catch (Exception ex)
           {
               lblError.Visible = true;
               lblError.Text = ex.Message;

           }

Please help
Posted
Updated 16-Jul-15 23:45pm
v3
Comments
Sergey Alexandrovich Kryukov 17-Jul-15 3:03am    
What is calender?
—SA
v2vinoth 17-Jul-15 3:03am    
Outlook calender
Dude Sergey is telling you that it is "Calendar" not "Calender". :)
Sergey Alexandrovich Kryukov 17-Jul-15 11:09am    
It would be perfectly fine if if was a typo, but thousands repeat the same exact word all the time.
—SA

1 solution

this is incredible complicated thing. I had the same problem with appointments some time ago. Spent about 12 hours on it. What you should try to do first: add "Meeting.ics" in the attachment. Try different content types: multipart/alternative, with AlternateViews.

http://stackoverflow.com/questions/461889/sending-outlook-meeting-requests-without-outlook[^]

C#
// plaintext and HTML descriptions (HTML version is required by Outlook)
string bodyText = "Please come to project XYZ review meeting.";
string bodyHtml = "<p>Please come to project XYZ review meeting.</p>";

// appointment data - see http://tools.ietf.org/html/rfc2445 for details
string appointmentData =
    "BEGIN:VCALENDAR\n" +
    "PRODID:Rebex Mail\n" +
    "VERSION:2.0\n" +
    "BEGIN:VTIMEZONE\n" +
    "TZID:US-Eastern\n" +
    "BEGIN:STANDARD\n" +
    "DTSTART:19981025T020000\n" +
    "RDATE:19981025T020000\n" +
    "TZOFFSETFROM:-0400\n" +
    "TZOFFSETTO:-0500\n" +
    "TZNAME:EST\n" +
    "END:STANDARD\n" +
    "BEGIN:DAYLIGHT\n" +
    "DTSTART:19990404T020000\n" +
    "RDATE:19990404T020000\n" +
    "TZOFFSETFROM:-0500\n" +
    "TZOFFSETTO:-0400\n" +
    "TZNAME:EDT\n" +
    "END:DAYLIGHT\n" +
    "END:VTIMEZONE\n" +
    "BEGIN:VEVENT\n" +
    "DTSTAMP:19980309T231000Z\n" +
    "UID:guid-1.host1.com\n" +
    "ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\n" +
    "ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n" +
    "DESCRIPTION:Project XYZ Review Meeting\n" +
    "CATEGORIES:MEETING\n" +
    "CLASS:PUBLIC\n" +
    "CREATED:19980309T130000Z\n" +
    "SUMMARY:XYZ Project Review\n" +
    "DTSTART;TZID=US-Eastern:19980312T083000\n" +
    "DTEND;TZID=US-Eastern:19980312T093000\n" +
    "LOCATION:1CP Conference Room 4350\n" +
    "END:VEVENT\n" +
    "END:VCALENDAR\n";  

// construct the calendar view
AlternateView appointment = new AlternateView();
appointment.SetContent(appointmentData, "text/calendar");
appointment.ContentType.Parameters.Add("method", "REQUEST");

// construct the message
MailMessage message = new MailMessage();
message.BodyText = bodyText;
message.BodyHtml = bodyHtml;
message.AlternateViews.Add(appointment);

// save the message
message.Save(...);
 
Share this answer
 

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