79442367

Date: 2025-02-15 23:20:09
Score: 2
Natty:
Report link

As mentioned by Raghavendra N and EvilDr there does not seem to be a working solution.

As I tested sending these icalendar requests, I noted something interesting which could be used as "some kind of hack".

When you are "the organizer of the meeting" you do not need to respond.

So when you send an invite to person A and you configure the meeting to be organized by person A, he/she will not get the options to accept/temporary accept/reject.

@EvilDr, is it possible for you to code your requests so that each invitation is send individually, so you can "patch" the organizer of the meeting to be the one you are inviting? If so, this should fix your problem.

I am a starter on StackOverflow, so my score is still low, otherwise I would have added this as a comment. Adding it as "an answer" is the only possibility for me.

This is the code which gave me the "you are the organizer, so you do not need to react" response:

using System.Net.Mail;
using System.Net.Mime;
using System.Text;

var from = "sender@mailserver";
var subj = "TEST EMAIL " + DateTime.Now.ToString("G");
var body = "We do not handle accepting/temporary accepting/decling the appointment it is automatically accepted.";
var recipient = "recipient@mailserver";
var recipientName = "Name of Recipient";

MailMessage msg = new MailMessage();
msg.From = new MailAddress(from);
msg.To.Add(recipient);
msg.Subject = subj;

AlternateView avBody = AlternateView.CreateAlternateViewFromString(body, Encoding.UTF8, MediaTypeNames.Text.Html);
msg.AlternateViews.Add(avBody);


// Generate Calendar Invite ---------------------------------------------------  
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}", DateTime.Now.AddMinutes(+330)));
str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+660)));
str.AppendLine("LOCATION: " + "online TEAMS LINK");
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.To[0].Address));

str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=FALSE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));

str.AppendLine("BEGIN:VALARM");
str.AppendLine("TRIGGER:-PT15M");
str.AppendLine($"ACTION;RSVP=FALSE;CN=\"{recipientName}\":MAILTO:{recipient}");
str.AppendLine("DESCRIPTION:Reminder");
str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");
str.AppendLine("END:VCALENDAR");


// Attach Calendar Invite ------------------------------------------------------  
byte[] byteArray = Encoding.ASCII.GetBytes(str.ToString());
MemoryStream stream = new MemoryStream(byteArray);

Attachment attach = new Attachment(stream, "invite.ics");
attach.TransferEncoding = TransferEncoding.QuotedPrintable;
msg.Attachments.Add(attach);

ContentType contype = new ContentType("text/calendar");
contype.CharSet = "UTF-8";
contype.Parameters.Add("method", "REQUEST");
contype.Parameters.Add("name", "invite.ics");

AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), contype);
avCal.TransferEncoding = TransferEncoding.QuotedPrintable;
msg.AlternateViews.Add(avCal);

//Now sending a mail with attachment ICS file. ----------------------------------  
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "mailserver";
smtpclient.EnableSsl = true;
smtpclient.Port = 587;
smtpclient.Credentials = new System.Net.NetworkCredential("username", "password");
smtpclient.Send(msg);
Console.WriteLine("Email Sent");
Console.ReadLine();
Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @EvilDr
  • Low reputation (1):
Posted by: lordofcode