I create a workflow that sends notification email, which is triggered by "Appointment created" event.
I want it to send meeting invitation (which could be accepted/rejected in Outlook), not the regular email, what is the trick here?
Create a mail message as a custom workflow activity and send it via SMTP :
Sample approach in code below - note, not production ready. You need to understand the iCal properties you want to set and slot this into the boilerplate workflow activity code accordingly.
// 3rd party libraries to reference
using DDay.iCal;
using DDay.iCal.Serialization.iCalendar;
...
...
// Create the iCal
IICalendar iCal = new iCalendar();
iCal.Method = "Request";
...
...
IEvent evt = iCal.Create<Event>();
evt.Summary = summary;
evt.Start = new iCalDateTime(eventstartDt).SetTimeZone(local);
evt.End = new iCalDateTime(eventendDt).SetTimeZone(local);
var serializer = new iCalendarSerializer(iCal);
var iCalString = serializer.SerializeToString(iCal);
...
...
var mailMessage = new MailMessage
{
Subject = Summary.Get(_executionContext),
From = new MailAddress(FromEmailAddress.Get(_executionContext))
};
// Create the Alternate view object with Calendar MIME type
var ct = new System.Net.Mime.ContentType("text/calendar");
if (ct.Parameters != null) ct.Parameters.Add("method", "REQUEST");
//Provide the framed string here
AlternateView avCal = AlternateView.CreateAlternateViewFromString(iCalString, ct);
mailMessage.AlternateViews.Add(avCal);
// Send email
try
{
smtpClient.Send(mailMessage);
}
catch (Exception ex)
{
// Log it.
}