12

I'm creating an application in C#. In this i can create a meeting request that is sent to the user through code and appears in Outlook mail.

The below code is what I am using to send the meeting invitation. It is working fine.

StringBuilder OutlookBody = new StringBuilder();
string textvs = @"BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
VERSION:1.0
BEGIN:VEVENT
LOCATION:" + Location + @"
DTSTART:" + string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", start) + @"
DTEND:" + string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", end) + @"
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:= " + OutlookBody + @"=0D=0A SUMMARY:" + AppoitmentName + @"
PRIORITY:3
END:VEVENT
END:VCALENDAR";

How can i use the same code to remove outlook meeting request.

I have also checked this answer, but it didn't solve my problem.

slugster
  • 49,403
  • 14
  • 95
  • 145
Deepak gupta
  • 1,938
  • 11
  • 11
  • please specify reason for downvoting so that I can modify it. @downvoter – Deepak gupta Jan 28 '17 at 12:39
  • I'm not the downvoter, but could you tell us why the answer you mentioned did not help? it looks as it was exactly on the spot. you won't be able to achieve a forced deletion, it is always another message that the recipient will see as a notification like "meeting canceled - remove from calendar?" – Cee McSharpface Jan 29 '17 at 20:14
  • @dlatikay: This code is working fine to send outlook meeting request. I want to send outlook meeting cancellation by modifying this code, might be adding status as cancelled. I don't know what to do exactly. – Deepak gupta Jan 31 '17 at 05:31
  • Are you sending an email to outlook, creating ICS files and import them, using COM interop? It isn't clear from your question. It seems there is an issue with ICS import (it doesn't process the cancelled event) – Niels V Jan 31 '17 at 10:26
  • @NielsV Yes i am sending email to outlook, creating vcs file. When user open this file and save then meeting is save in outlook as an appointment. – Deepak gupta Feb 01 '17 at 05:15

4 Answers4

2

In OutLook every appointment/meeting will get a unique Id and a ChangeKey. A new ChangeKey is generated whenever there is a modification done to the meeting. To update an existing meeting you must have the Id and latest ChangeKey.

In your approach, if I am not wrong, you are just constructing an ICAL which is added to the outlook via email. In this case, you will not have the Id and ChangeKey to modify the meeting programatically. I would rather suggest you to change the approach.

If you have Microsoft Exchange the following links will guide. Else, ignore the links.

https://msdn.microsoft.com/en-us/library/office/dn495611(v=exchg.150).aspx https://msdn.microsoft.com/en-us/library/office/dn495612(v=exchg.150).aspx

Rama Kathare
  • 920
  • 9
  • 29
2

You can set the method and status of the meeting by adding these lines:

METHOD: CANCEL

STATUS: CANCELLED

See more here.

jomsk1e
  • 3,585
  • 7
  • 34
  • 59
0

Use the following code

StringBuilder OutlookBody = new StringBuilder();
string textvs = @"BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
VERSION:1.0
BEGIN:VEVENT
LOCATION:" + Location + @"
DTSTART:" + string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", start) + @"
DTEND:" + string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", end) + @"
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:= " + OutlookBody + @"=0D=0A SUMMARY:" + AppoitmentName + @"
PRIORITY:3
METHOD:CANCEL
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR";

And use the following Mime Type

System.Net.Mime.ContentType mimeType = new System.Net.Mime.ContentType("text/calendar; method=CANCEL");

AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType);
message.AlternateViews.Add(alternate);
Vikas Sardana
  • 1,593
  • 2
  • 18
  • 37
0

I solved this issue by changing some lines in code.

  1. Change method from REQUEST to CANCEL ==> str.AppendLine("METHOD:CANCEL");

  2. Change Status to Cancelled ==> str.AppendLine("STATUS:CANCELLED");

  3. In System.Net.Mime.ContentType contype = newSystem.Net.Mime.ContentType("text/calendar"); change method from REQUEST to CANCEL ==> contype.Parameters.Add("method", "CANCEL");

Yusef Maali
  • 2,201
  • 2
  • 23
  • 29