0 votes
by (180 points)

How can I find out if a received email is a calendar invitation (text/calendar)?

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (144k points)

The "text/calendar" part of invitation emails is accessible via MailMessage object's AlternateViews collection:

var imap = new Imap();
// connect, authenticate, and so on...
...
MailMessage message = imap.GetMailMessage(uniqueId);

// search for 'text/calendar' part
AlternateView invitation = message.AlternateViews.FirstOrDefault(view => view.ContentType.MediaType == "text/calendar");
if (invitation != null)
{
    string data = invitation.ContentString;

    // process invitation data here
    ...
}

However, Rebex Secure Mail does not include an API for parsing the invitation data (see RFC 2445 for details).

by (180 points)
Thank you for the answer. We want to archive the emails, but calendar invitations should not be archived. Not all calendar invitations have an AlternateView with the MediaType text/calendar. Is there another way to recognize calendar invitations?
by (144k points)
Are those RFC 2445 / RFC 5545 calendar invitation as well? If they are, there should be an AlternativeView with text/calendar media type. If there isn't, or if the invitations are in a different format, would it be possible to share a sample message with us?
...