首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Vcalendar中动态设置" to“字段?

如何在Vcalendar中动态设置" to“字段?
EN

Stack Overflow用户
提问于 2013-03-04 16:16:23
回答 1查看 277关注 0票数 1

我需要在" to“字段中设置登录用户的电子邮件地址,同时导出到Vcalendar。

代码语言:javascript
复制
public static void ExportToIcalender(HttpContext ctx, DateTime startDate, DateTime endDate, string organizer, string location, string summary, string description)
{
    string DateFormat = "yyyyMMddTHHmmssZ";
    ctx.Response.ClearContent();
    ctx.Response.ContentType = "text/calendar";
    ctx.Response.AddHeader("Content-disposition", "attachment; filename=appointment.ics");

    ctx.Response.Write("BEGIN:VCALENDAR");
    ctx.Response.Write("\nVERSION:2.0");
    ctx.Response.Write("\nMETHOD:PUBLISH");
    ctx.Response.Write("\nBEGIN:VEVENT");
    **ctx.Response.Write("\nORGANIZER:MAILTO:" + organizer);**

    ctx.Response.Write("\nDTSTART:" + startDate.ToUniversalTime().ToString(DateFormat));
    ctx.Response.Write("\nDTEND:" + endDate.ToUniversalTime().ToString(DateFormat));
    ctx.Response.Write("\nLOCATION:" + location);
    ctx.Response.Write("\nUID:" + DateTime.Now.ToUniversalTime().ToString(DateFormat) + "@mysite.com");
    ctx.Response.Write("\nDTSTAMP:" + DateTime.Now.ToUniversalTime().ToString(DateFormat));
    ctx.Response.Write("\nSUMMARY:" + summary);
    description = HtmlRemoval.StripTagsRegexCompiled(description).Replace("\r\n", "\\n");
    ctx.Response.Write("\nDESCRIPTION:" + description);
    ctx.Response.Write("\nPRIORITY:5");
    ctx.Response.Write("\nCLASS:PUBLIC");
    ctx.Response.Write("\nEND:VEVENT");
    ctx.Response.Write("\nEND:VCALENDAR");
    ctx.Response.End();
}

这一行对我没有帮助:

代码语言:javascript
复制
ctx.Response.Write("\nORGANIZER:MAILTO:" + organizer)

请提供解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-04 16:25:51

您可以通过设置attendee属性来执行此操作

代码语言:javascript
复制
ctx.Response.Write("\nATTENDEE;CN=someone@email.com;RSVP=TRUE:mailto:someone@email.com");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15197218

复制
相关文章

相似问题

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