我创建了一个发送通知电子邮件的工作流程,该工作流程由“约会创建”事件触发。
我希望它发送会议邀请(可以在Outlook中接受/拒绝),而不是常规电子邮件,这里的诀窍是什么?
答案 0 :(得分:1)
将邮件消息创建为自定义工作流活动并通过SMTP发送:
以下代码中的示例方法 - 注意,而不是生产就绪。您需要了解要设置的iCal属性,并将其相应地插入到样板工作流活动代码中。
// 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.
}