Skip to content

Commit 88566a4

Browse files
committed
fixed event updating
1 parent 0ff3b91 commit 88566a4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sql_clr_ics/clr_send_ics_invite.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ INNER JOIN [msdb].[dbo].[sysmail_server] AS s
313313
ics_contents_str.AppendLine(string.Format("STATUS:{0}", (method.Value == "CANCEL") ? "CANCELLED" : "CONFIRMED"));
314314
ics_contents_str.AppendLine("TRANSP:OPAQUE");
315315
ics_contents_str.AppendLine(string.Format("SEQUENCE:{0}", sequence.Value));
316+
ics_contents_str.AppendLine(string.Format("X-MICROSOFT-CDO-APPT-SEQUENCE:{0}", sequence.Value));
316317

317318
ics_contents_str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", start_time_utc.Value));
318319
ics_contents_str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", timestamp_utc.Value));
@@ -325,7 +326,8 @@ INNER JOIN [msdb].[dbo].[sysmail_server] AS s
325326
ics_contents_str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE={0}:{1}", body_format.Value == "HTML" ? "text/html" : "text/plain", body.Value));
326327

327328
ics_contents_str.AppendLine(string.Format("SUMMARY:{0}", subject.Value));
328-
ics_contents_str.AppendLine(string.Format("ORGANIZER:SENT-BY=\"mailto:{0}\";MAILTO:{0}", msg.From.Address));
329+
ics_contents_str.AppendLine(string.Format("ORGANIZER:{0}", msg.From.Address));
330+
//ics_contents_str.AppendLine(string.Format("ORGANIZER:SENT-BY=\"mailto:{0}\";MAILTO:{0}", msg.From.Address));
329331
ics_contents_str.AppendLine(string.Format("CLASS:{0}", sensitivity.Value.ToUpper()));
330332

331333
switch (mailPriority)
@@ -345,37 +347,38 @@ INNER JOIN [msdb].[dbo].[sysmail_server] AS s
345347

346348
string rsvp_string = (require_rsvp.Value ? "PARTSTAT=NEEDS-ACTION;RSVP=TRUE" : "PARTSTAT=ACCEPTED;RSVP=FALSE");
347349
bool organizer_in_recipients = false;
350+
string lineSeparator = " "; // Environment.NewLine;
348351

349352
foreach (MailAddress addr in msg.To)
350353
{
351354
if (addr.Address == msg.From.Address) organizer_in_recipients = true;
352-
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, recipients_role.Value.ToUpper(), Environment.NewLine));
355+
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, recipients_role.Value.ToUpper(), lineSeparator));
353356
}
354357

355358
foreach (MailAddress addr in msg.CC)
356359
{
357360
if (addr.Address == msg.From.Address) organizer_in_recipients = true;
358-
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, copy_recipients_role.Value.ToUpper(), Environment.NewLine));
361+
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, copy_recipients_role.Value.ToUpper(), lineSeparator));
359362
}
360363

361364
foreach (MailAddress addr in msg.Bcc)
362365
{
363366
if (addr.Address == msg.From.Address) organizer_in_recipients = true;
364-
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, blind_copy_recipients_role.Value.ToUpper(), Environment.NewLine));
367+
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE={3};{4}{2};CN=\"{0}\";{4}X-NUM-GUESTS=0:mailto:{1}", addr.DisplayName, addr.Address, rsvp_string, blind_copy_recipients_role.Value.ToUpper(), lineSeparator));
365368
}
366369

367370
if (!organizer_in_recipients)
368371
{
369372
msg.Bcc.Add(msg.From);
370-
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=NON-PARTICIPANT;{2}PARTSTAT=ACCEPTED;RSVP=FALSE;CN=\"{0}\";{2}X-NUM-GUESTS=0:mailto:{1}", msg.From.DisplayName, msg.From.Address, Environment.NewLine));
373+
ics_contents_str.AppendLine(string.Format("ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=NON-PARTICIPANT;{2}PARTSTAT=ACCEPTED;RSVP=FALSE;CN=\"{0}\";{2}X-NUM-GUESTS=0:mailto:{1}", msg.From.DisplayName, msg.From.Address, lineSeparator));
371374
}
372375

373376
if (use_reminder && method.Value != "CANCEL")
374377
{
375378
ics_contents_str.AppendLine("BEGIN:VALARM");
376379
ics_contents_str.AppendLine(string.Format("TRIGGER:-PT{0}M", reminder_minutes.Value));
377380
ics_contents_str.AppendLine("ACTION:DISPLAY");
378-
ics_contents_str.AppendLine("DESCRIPTION:Reminder");
381+
ics_contents_str.AppendLine("DESCRIPTION:REMINDER");
379382
ics_contents_str.AppendLine("END:VALARM");
380383
}
381384

@@ -398,6 +401,7 @@ INNER JOIN [msdb].[dbo].[sysmail_server] AS s
398401
smtpclient.UseDefaultCredentials = use_default_credentials.Value;
399402
smtpclient.EnableSsl = enable_ssl.Value;
400403
smtpclient.Credentials = credentials;
404+
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
401405
System.Net.Mime.ContentType calendar_contype = new System.Net.Mime.ContentType("text/calendar;charset=UTF-8");
402406
calendar_contype.Parameters.Add("method", "REQUEST");
403407
calendar_contype.Parameters.Add("name", "Meeting.ics");

0 commit comments

Comments
 (0)