UPDATE
Ultimate goal is to send the updated body to the existing recipients of the meeting occurrence.
I'm trying to update HTMLBody of occurrence of existing meeting with number of recipients.
After updated the HTMLBody, recipients count is become zero.
And sending failed with an error saying "message contains no recipients"
Here's the code I've tried.
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>\r\n<html>\r\n<head>\r\n<title>Page Title</title>\r\n</head>\r\n<body>\r\n<p>This is a paragraph.</p>\r\n\r\n</body>\r\n</html>";
occurrence.Send();
}
}
}
catch (Exception e)
{
Debug.DebugMessage(2, $"Error in {MethodBase.GetCurrentMethod().Name} | {e.Message}");
}
finally
{
if (occurrence != null) Marshal.ReleaseComObject(occurrence);
}
}
I then tried the approach of adding and removing a recipient which worked but added recipient is not removed from the meeting request sent, although it was removed from the appointment in my calendar.
Here's the code I've tried for that.
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>\r\n<html>\r\n<head>\r\n<title>Page Title</title>\r\n</head>\r\n<body>\r\n<p>This is a paragraph.</p>\r\n\r\n</body>\r\n</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);
}
}
}