Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do we update/remove attachments? #565

Open
aldrashan opened this issue Jan 12, 2023 · 1 comment
Open

How do we update/remove attachments? #565

aldrashan opened this issue Jan 12, 2023 · 1 comment

Comments

@aldrashan
Copy link

We're exporting a calendar event via EWS and importing it in a Ical.Net.Calendar object.
This event already has attachments, but the data is missing (EWS doesn't export it, so that's normal).
I want to update the existing attachments, but the Data property isn't settable nor is there any other method to update the contents.
I also can't remove any attachments.
If I were to clear the "ATTACH" group inside the Properties, the attachments are all gone, but then you can't add attachments anymore via the Attachments property.
The wiki also doesn't tell us anything about this.

@aldrashan
Copy link
Author

I've now tried copying the calendar object manually, leaving the attachments empty and re-adding them.

var newCalendar = new Ical.Net.Calendar();
var vEvent = new Ical.Net.CalendarComponents.CalendarEvent
{
    Attendees = calendarEvent.Attendees,
    ...
}
newCalendar.Events.Add(vEvent);
vEvent.Attachments = newAttachments;
var serializer = new CalendarSerializer();
var serializedCalendar = serializer.SerializeToString(newCalendar);

My attachment data only get serialized when you don't specify a URI.
You can't combine byte[] data and an URI. The URI will take priority and your data won't get serialized.
So how do we link attachments to their inline cid (i.e. name them and mark them as inline)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant