I am using iCal.Net to send meeting invitations. It's working fine on Gmail and it's showing me event like:
But on Outlook it's not showing me any invite like accept, tentative, and decline options. It's showing me like:
It should be shown like this:
Here is my code:
async Task<SendResponse> CreateCalendarEventAsync(
CalendarNotificationModel calendarNotificationModel)
{
var attendees = calendarNotificationModel.Attendees.Select(x => new
Ical.Net.DataTypes.Attendee()
{
CommonName = x.AttendeeName,
ParticipationStatus = "REQ-PARTICIPANT",
Rsvp = true,
Role = "REQ-PARTICIPANT",
Value = new Uri($"mailto:{x.AttendeeEmail}")
}).ToList();
var e = new CalendarEvent
{
Summary = calendarNotificationModel.Name,
IsAllDay = true,
Organizer = new Organizer()
{
CommonName = "HRMatrix",
Value = new Uri("mailto:xyz@zxy.com")
},
Attendees = attendees,
Status = "Confirmed",
Sequence = 0,
Start = new CalDateTime(calendarNotificationModel.StartDateTime),
End = new CalDateTime(calendarNotificationModel.EndDateTime),
Transparency = TransparencyType.Opaque,
Location = calendarNotificationModel.Location,
Description = calendarNotificationModel.Description
};
var calendar = new Calendar();
calendar.AddProperty("X-MS-OLK-FORCEINSPECTOROPEN", "TRUE");
calendar.AddProperty("METHOD", "REQUEST");
calendar.Events.Add(e);
var serializer = new CalendarSerializer();
var serializedCalendar = serializer.SerializeToString(calendar);
var bytesCalendar = Encoding.ASCII.GetBytes(serializedCalendar);
MemoryStream ms = new MemoryStream(bytesCalendar);
using (ms)
{
ms.Position = 0;
SmtpClient smtp = new SmtpClient
{
//The address of the SMTP server (I'll take mailbox 126 as an example, which can
be set according to the specific mailbox you use)
Host = "smtp.gmail.com",
EnableSsl = true,
Port = 587,
DeliveryMethod = SmtpDeliveryMethod.Network,
//Enter the user name and password of your sending SMTP server here
Credentials = new NetworkCredential("xyz@xyz", "sdfsdfsdfsdf")
};
//Set default sending information
Email.DefaultSender = new SmtpSender(smtp);
var email = Email
//Sender
.From("xyz@xyz")
//Addressee
.To("denis@org.com")
//Message title
.Subject("Interview")
//Email content
.Body("You are invited.");
//Determine whether the transmission is successful according to the transmission
result
var attachment = new FluentEmail.Core.Models.Attachment
{
Data = ms,
ContentType = "text/calendar",
Filename = "invite.ics",
};
email.Attach(attachment);
var result = email.Send();
//Or send it asynchronously
//await email.SendAsync();
return result;
}
}
Here is my .ics file:
BEGIN:VCALENDAR
METHOD:Request
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
ATTENDEE;CN=XYZ;PARTSTAT=REQ-PARTICIPANT;RSVP=TRUE;ROLE=REQ-PARTICIPA
NT:mailto:XYZ@hotmail.com
DESCRIPTION:You are invited to give an interview
DTEND:20220208T091006
DTSTAMP:20220207T181006Z
DTSTART:20220208T041006
LOCATION:Pakistan
ORGANIZER;CN=HRMatrix:mailto:xyz@gmail.com
SEQUENCE:0
STATUS:Confirmed
SUMMARY:XYZ
TRANSP:OPAQUE
UID:b2ddc1ef-a2e4-4b0e-afa0-27d9689fbsdf
END:VEVENT
END:VCALENDAR
PS: if I send the above .ics file from Gmail client it works but it does not work from my SMTP client.