We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How could I modify recipients in modified occurrence of event?

Hello,
I load calendars from PST using Aspose.Email 21.5 with C#.
For example,

var ps = PersonalStorage.FromFile({pstpath});
var folders = ps.RootFolder.GetSubFolders();
var calendarFolder = folders.Find(f => f.DisplayName.Equals("Calendar", StringComparison.OrdinalIgnoreCase));
var items = calendarFolder.GetContents();
foreach (var i in items)
 {
       var message = ps.ExtractMessage(i);`
        var calendar = message.ToMapiMessageItem() as MapiCalendar;
}

Then I can get a MapiCalendar called calendar.
But how can I get the modified occurrence of this event?
In
calendar.Recurrence.RecurrencePattern.Exceptions
I can find exception info
It only contains summary , location but there is no information of recipients.
How could I get the recipients in modified occurrence?
And how to modify the recipients in modified occurrence and save it back to the origin calendar?
Thanks,

@xieming95at163.com,
Thank you for the questions. I added a ticket with ID EMAILNET-40275 in our tracking system. Our development team will prepare information for you. I will answer you later.

Hello,
recently I find a way to modify the embedded message (exceptional occurrence)
Sample Code here:

  MapiCalendar calendar;//a mapi calendar object
            for (var i2 = 0; i2 < calendar.Attachments.Count; i2++)
            {
                var embedMessage = calendar.Attachments[i2];
                var eMessage = embedMessage.ObjectData.ToMapiMessage();
                var cccc = eMessage.ToMapiMessageItem() as MapiCalendar;
                cccc.Attendees.AppointmentRecipients = new MapiRecipientCollection();
                cccc.Attendees.AppointmentRecipients.Add("xieming95@163.com", "xm", MapiRecipientType.MAPI_TO);
                cccc.Save("F:\\1.msg", Aspose.Email.Calendar.AppointmentSaveFormat.Msg);
                var newMessage = MapiMessage.Load("F:\\1.msg", new MsgLoadOptions() { PreserveEmbeddedMessageFormat = true, PreserveTnefAttachments = true });
                newMessage.SetProperty(KnownPropertyList.AppointmentStateFlags, 1);
                calendar.Attachments.Replace(i2, "", newMessage);
            }

In my test, it was working well. Is this a available method to modify the exceptional occurrence? Or is there any potential problem?
Thanks

@xieming95at163.com

I have associated the information in our issue tracking system and will share the further feedback with you as soon as the issue will be addressed.

Hello
Is there any updates for this issue?
Thanks,

@xieming95at163.com

I request for your patience and will share the good news with you as soon as the issue will be fixed. At the moment there are no updates for the status of the issue.

@xieming95at163.com,
Our development team investigated the issue. You can use that way to replace participants. But pay attention to the following:

  1. There is no need to convert the message to the calendar and vice versa, the collections of the participants are overwritten at this conversion.
  2. You should not remove from the occurrence participants who are common for the meeting.
  3. After replacing the attachment, you need to set some properties of the attachment as shown in the code below.
MapiMessage main = MapiMessage.FromFile(fileName);
MapiMessage inner = main.Attachments[0].ToMapiMessage();
List<MapiRecipient> fordelete = new List<MapiRecipient>();
foreach (var item in inner.Recipients)
{
    if (!ContainsAddress(item.EmailAddress, main.Recipients))
        fordelete.Add(item);
}
foreach (var rec in fordelete)
{
    inner.Recipients.Remove(rec);
}

inner.Recipients.Add("xxx@yyy.com", "xxx yyy", MapiRecipientType.MAPI_TO);
inner.Recipients.Add("ccc@ddd.com", "ccc ddd", MapiRecipientType.MAPI_TO);

main.Attachments.Replace(0, "", inner);
main.Attachments[0].SetPropertyLong(MapiPropertyTag.PR_ATTACHMENT_HIDDEN, 1);
main.Attachments[0].SetPropertyLong(MapiPropertyTag.PR_ATTACHMENT_FLAGS, 2); //2 - afException

var opt = new MailConversionOptions() { ConvertAsTnef = true, KeepOriginalEmailAddresses = true, PreserveEmbeddedMessageFormat = true };
var mailMessage = main.ToMailMessage(opt);

NetworkCredential credentials = new NetworkCredential("address@domen.com", "password");
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", credentials);
client.AppendMessage("Calendar", mailMessage);
private static bool ContainsAddress(string address, MapiRecipientCollection col)
{
    foreach (MapiRecipient recipient in col)
    {
        if (recipient.EmailAddress == address)
        {
            return true;
        }
    }

    return false;
}

Documents: Working with Outlook Calendar Items