更新Outlook Redemption会议实例HTMLBody后收件人清零问题求助
更新说明
最终目标:将更新后的会议内容发送给该会议实例的现有收件人。
尝试更新一个已有多个收件人的周期性会议实例的HTMLBody,但更新后收件人数量变为0,发送时失败并提示“邮件无收件人”。
以下是第一次尝试的代码:
public static void GetSomething() { var entryID = "00000000C97FEB5BB4BE2046B4C77ADEB3C423010700BA6ADFD7533DD244B122D7B9F3B5664000000000010D0000BA6ADFD7533DD244B122D7B9F3B56640000269310F930000"; RDOAppointmentItem appointment = null; RDORecurrencePattern pattern = null; RDOMail occurrence = null; try { appointment = rSession.GetMessageFromID(entryID) as RDOAppointmentItem; if (appointment != null) { pattern = appointment.GetRecurrencePattern(); if (pattern != null) { occurrence = pattern.GetOccurrence(1); if (pattern != null) Marshal.ReleaseComObject(pattern); if (appointment != null) Marshal.ReleaseComObject(appointment); occurrence.HTMLBody = @"<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <p>This is a paragraph.</p> </body> </html>"; occurrence.Send(); } } } catch (Exception e) { Debug.DebugMessage(2, $"Error in {MethodBase.GetCurrentMethod().Name} | {e.Message}"); } finally { if (occurrence != null) Marshal.ReleaseComObject(occurrence); } }
之后尝试了添加再删除收件人的方法,该方法能发送邮件,但发送的会议请求中新增的收件人并未被移除,尽管本地日历中的会议实例里该收件人已被移除。
以下是对应的尝试代码:
public static void GetSomething() { var entryID = "00000000C97FEB5BB4BE2046B4C77ADEB3C423010700BA6ADFD7533DD244B122D7B9F3B5664000000000010D0000BA6ADFD7533DD244B122D7B9F3B56640000269310F930000"; RDOAppointmentItem appointment = null; RDORecurrencePattern pattern = null; RDOMail occurrence = null; try { appointment = rSession.GetMessageFromID(entryID) as RDOAppointmentItem; if (appointment != null) { pattern = appointment.GetRecurrencePattern(); if (pattern != null) { occurrence = pattern.GetOccurrence(1); if (pattern != null) Marshal.ReleaseComObject(pattern); if (appointment != null) Marshal.ReleaseComObject(appointment); RDORecipients oldRecipients = occurrence.Recipients; var oldRecCount = oldRecipients.Count; RDORecipient recipient = oldRecipients.AddEx("Test", "test@gmail.com", "SMTP", 1); if (recipient != null) Marshal.ReleaseComObject(recipient); if (oldRecipients != null) Marshal.ReleaseComObject(oldRecipients); occurrence.HTMLBody = @"<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <p>This is a paragraph.</p> </body> </html>"; RDORecipients newRecipients = occurrence.Recipients; newRecipients.Remove(oldRecCount + 1); if (newRecipients != null) Marshal.ReleaseComObject(newRecipients); occurrence.Send(); } } } catch (Exception e) { Debug.DebugMessage(2, $"Error in {MethodBase.GetCurrentMethod().Name} | {e.Message}"); } finally { if (occurrence != null) Marshal.ReleaseComObject(occurrence); } } }
内容的提问来源于stack exchange,提问作者Kvu
相关产品推荐
相关产品推荐

