0

我正在尝试回复通过 Outlook 2013 发送的会议邀请。为此,我正在使用 DDay.iCal 库和以下代码:

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;
}

现在,当在备用视图中通过 SMTP 发送生成的 ics 字符串时,会议似乎是从原始收件人发送的,而不是来自会议邀请收件人的响应。

// 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);

我错过了什么?

4

1 回答 1

0

method需要在内容类型标头和 iCalendar 属性中设置和不设置REPLY。这可能不是唯一的问题,但它是最明显的问题。REQUESTPUBLISHMETHOD

如果这不能解决问题,请分享您正在生成的实际电子邮件 + 标头。

于 2016-03-14T18:46:32.190 回答