0

I'm trying to reply to a meeting invitation sent via Outlook 2013. For that, I'm using the DDay.iCal library and the following code:

public static string GenerateAppointmentResponse(Appointment importedAppointment, MeetingRequestAcceptanceType acceptanceType)
{
    var iCal = new iCalendar
    {
        Method = "PUBLISH",
        Version = "2.0",
        ProductID = MyhProductIdentifier
    };

    var evt = iCal.Create<Event>();

    switch (importedAppointment.PrivacyStatus)
    {
        case AppointmentPrivacyStatus.None:
            evt.Class = "PRIVATE";
            evt.Transparency = TransparencyType.Opaque;
            break;
        case AppointmentPrivacyStatus.AvailabilityOnly:
            evt.Class = "PUBLIC";
            evt.Transparency = TransparencyType.Transparent;
            break;
        case AppointmentPrivacyStatus.LimitedDetails:
            evt.Class = "PUBLIC";
            evt.Transparency = TransparencyType.Transparent;
            break;
        case AppointmentPrivacyStatus.FullDetails:
            evt.Class = "PUBLIC";
            evt.Transparency = TransparencyType.Transparent;
            break;
        default:
            throw new ArgumentOutOfRangeException();
    }

    evt.Summary = importedAppointment.Subject;
    evt.Start = new iCalDateTime(importedAppointment.Start);
    evt.Duration = importedAppointment.End - importedAppointment.Start;
    evt.Description = importedAppointment.Description;
    evt.Location = importedAppointment.Location;
    evt.IsAllDay = importedAppointment.IsAllDay == true;
    evt.UID = importedAppointment.ICalendarUid;

    string organizer = importedAppointment.CreatedBy ?? Environment.UserName;
    if (string.IsNullOrWhiteSpace(organizer))
    {
        throw new Exception("The Organizer is mandatory.");
    }

    evt.Organizer = new Organizer(organizer);

    if (!string.IsNullOrWhiteSpace(importedAppointment.RecurrenceInfo))
    {
        var rp = new RecurrencePattern(importedAppointment.RecurrenceInfo);
        evt.RecurrenceRules.Add(rp);
    }

    //// REQUEST will update an existing event with the same
    //// UID (Unique ID) and a newer time stamp.
    //if (updatePreviousEvent)
    //{
    //    iCal.Method = "REQUEST";
    //}

    string result = new iCalendarSerializer().SerializeToString(iCal);
    return result;
}

Now when sending the generated ics string via SMTP in an alternate view, the meeting appears to be sent from the original recipient and not like a response from the recipient of the meeting invitation.

// Construct the calendar view
string appointmentData = CalendarHelper.GenerateAppointment(meetingRequestResponse.ImportedAppointment, meetingRequestResponse.AcceptanceType);

var appointment = new AlternateView();
appointment.SetContent(appointmentData, "text/calendar");
appointment.ContentType.Parameters.Add("method", "REQUEST");

// Construct the message
var mailMessage = new MailMessage();
mailMessage.AlternateViews.Add(appointment);

What am I missing?

SeToY
  • 5,777
  • 12
  • 54
  • 94

1 Answers1

0

The method needs to be set to REPLY and not REQUEST or PUBLISH in both the content-type header and METHOD iCalendar property. That might not be the only problem, but it's the most obvious one.

If that doesn't solve it, share the actual email you're generating + headers.

Evert
  • 93,428
  • 18
  • 118
  • 189