首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用DDay.iCal的iCalendar请求响应

使用DDay.iCal的iCalendar请求响应
EN

Stack Overflow用户
提问于 2016-03-14 23:36:00
回答 1查看 996关注 0票数 0

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

代码语言:javascript
复制
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字符串时,会议看起来像是从原始收件人发送的,而不像是来自会议邀请收件人的响应。

代码语言:javascript
复制
// 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);

我遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2016-03-15 02:46:32

在content-type标头和METHOD iCalendar属性中,method都需要设置为REPLY,而不是REQUESTPUBLISH。这可能不是唯一的问题,但它是最明显的问题。

如果这还不能解决问题,那就分享你正在生成的实际邮件头吧。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35991799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档