I am attempting to attach an ICS file so that the recipient will see it as event in Outlook as opposed to an attachment.
I am 2 characters shy of producing an email with an identical attachment and I suspect this is the cause of why Outlook is still treating the ICS file as an attachment.
This is what Google Calendar produces and this work as expected (Outlook presents it as an event that I can RSVP to ):
Content-Type: application/ics; name="invite.ics"
Content-Disposition: attachment; filename="invite.ics"
Content-Transfer-Encoding: base64
I've unsuccessfully attempted to reproduce this.
My first attempt was:
byte[] byteArray = Encoding.UTF8.GetBytes(ics2);
MemoryStream stream = new MemoryStream(byteArray);
Attachment a = new Attachment(stream, "invite.ics", "application/ics");
a.ContentDisposition.DispositionType = @"attachment; filename=""invite.ics""";
which produced the following attachment (almost identical but missing the 2 double-quotes around invite.ics)
Content-Type: application/ics; name=invite.ics
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="invite.ics"
My second attempt was to add double-quotes:
byte[] byteArray = Encoding.UTF8.GetBytes(ics2);
MemoryStream stream = new MemoryStream(byteArray);
Attachment a = new Attachment(stream, @"""invite.ics""", "application/ics");
a.ContentDisposition.DispositionType = @"attachment; filename=""invite.ics""";
but this produces the content type name with escaped double-quotes (which I don't need or want).
Content-Type: application/ics; name="\"invite.ics\""
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="invite.ics"
How do I set the attachment content type name with only double-quotes around the name value: "invite.ics"