1

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);
        }
    }
}

 

Kvu
  • 169
  • 9

1 Answers1

1

Keep in mind that occurrences do not physically exist - when you ask for an occurrence, Redemption creates a fake appointment object that gets most of its properties (except for the start/end and recurrence) from the master appointment.

When you create an exception (by modifying one of the properties), besides modifying the exception pattern, an appointment is created and added an an embedded message attachment to the master appointment. That appointment stores mostly modified properties. Since the recipients were not modified for the exception, the recipient table is empty.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • I'm trying to do is update the body of occurrence and send that. So the first method is not worked; I tried to add a new recipient and then try to update the body. In that case the mail is sending but the occurrence is not updating. After that I added new recipient then update the body and removed that recipient. In that case recipient is not removing and also mail is sending but the occurrence is not updating. Please guide me to do this. I just need to update the body and send. – Kvu Feb 02 '23 at 11:38
  • Are you sending just that occurrence or the master appointment? – Dmitry Streblechenko Feb 02 '23 at 21:16
  • Just the occurrence I'm trying to send with updated body – Kvu Feb 03 '23 at 03:09
  • I've modified the code. Would you be kind enough to check that? – Kvu Feb 03 '23 at 10:01
  • Try to send the parent appointment instead. – Dmitry Streblechenko Feb 03 '23 at 15:27
  • @DmitryStreblechenko sending the parent appointment does not send the updated body in the above case. In other words exceptions aren't getting sent when you send the parent appointment using redemption. Any other alternatives we could try ? – Chathum Henegama Feb 06 '23 at 04:15
  • You need to save the exception first. Do you see the right body if you open that recurrence instance in the organizer's Calendar? – Dmitry Streblechenko Feb 06 '23 at 16:34
  • @DmitryStreblechenko We tried saving the occurences and openning them manuallly - we can see the updated body correctly. But when you send the master appointment it does not send the exceptions, recipients receives the master meeting request only, updated occurences are not received by recipients. In other words after sending the master, we opened the participants calendar and updated bodies can not be seen. – Chathum Henegama Feb 09 '23 at 06:01
  • @DmitryStreblechenko We also tried sending the updated master appointment using OOM and in that case all exceptions were sent as expected, this is not a solution for us since we would need to perform this operation in background. Any directions using redemption would be very helpful - thanks – Chathum Henegama Feb 09 '23 at 06:20