Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've had no problem sending an email (from gmail, to a gmail account) where the ICS calendar event is attached.

But I want to send it so that the user sees the event in the body of the email and can click yes/no, which, when I get these kinds of emails, automatically adds the event to my google calendar.

For the life of me I have not been able to get the ICS embedded in the BODY of the email!

What I have tried:

Lots of examples, here's one BradVin's .Net Blog - Creating vCalendars programmatically in C#[^] which does NOT put the calendar event into the body of the email. He's doing what everyone else is doing.

Follow up: If I send the email to an Outlook account, it shows up inline simply by setting the content disposition of the attached ICS file to inline --- snippet:

var att = new Attachment("meeting.ics", contype);
att.ContentDisposition.Inline = true;
msg.Attachments.Add(att);


But this discussion[^] talks about having to implement a multipart/mixed structure for gmail and yahoo!

Can anyone verify this?
Posted
Updated 16-Jan-19 10:10am
v3
Comments
ZurdoDev 16-Jan-19 15:10pm    
That's because you can't force an email client how to display attachments. Don't create an ICS. Create HTML instead.

1 solution

Maybe you should use:
msg.Headers.Add("Content-class", "urn:content-classes:calendarmessage");
See explanation here: c# - Send email to Outlook with ics meeting appointment - Stack Overflow[^]

There also is an interesting calendar library on GitHub: GitHub - rianjs/ical.net: ical.NET - an open source iCal library for .NET[^]
 
Share this answer
 
v2
Comments
Marc Clifton 17-Jan-19 8:27am    
Yes, I've been adding the urn. No affect.
RickZeeland 17-Jan-19 8:30am    
Well, it was worth a try :)
Richard Deeming 18-Jan-19 10:47am    
Did you add the ICS as an alternate view, instead of an attachment, as shown in that SO question?
var contype = new System.Net.Mime.ContentType("text/calendar");
contype.Parameters.Add("method", "REQUEST"); 
contype.Parameters.Add("name", "Meeting.ics");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), contype);
msg.AlternateViews.Add(avCal);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900