创建“可下载”使用 vObject (Python) 的 Outlook 的 vCalendar 对象

发布于 2024-09-04 10:38:54 字数 357 浏览 2 评论 0原文

我需要能够通过 vCalendar 对象为 Outlook 提供“可下载”事件 - 如果我没有记错的话。

根据我所做的研究,我被指出使用 vObject。我已经查看了他们的使用示例,但是之前没有使用该格式的经验,我不清楚如何解决我的问题,因为我不确定哪些字段可用,或者它们的名称是什么......

是有一个简单的示例,创建一个非常简单的对象/vCalendar 事件,具有某种类型的名称/描述,并且有开始和结束时间/日期?

我将使用 Django,并且可能只是根据要求动态创建这些用于“下载”。

I need to be able to offer "downloadable" events for Outlook, via vCalendar objects - if I'm not mistaken.

From the research I've done, I've been pointed at using vObject. I've looked at their usage examples, but having no prior experience with the format, it's not clear to me how to solve my problem, as I'm not sure what fields are available, or what they're called...

Is there a straighforward example of creating an very simple object/vCalendar event with some type of name/description, that has a start and end time/date?

I'll be using Django, and will probably just dynamically create these for "download" as requested.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

始终不够爱げ你 2024-09-11 10:38:54

我相信最有用的字段是:

  • dtstart:开始时间
  • dtend:结束时间
  • summary
  • location
  • url
  • description

然后你创建一个日历:

cal = vobject.iCalendar()

然后是一个事件:

event = cal.add('vevent')

并填充它:

event.add('summary').value = 'your summary'
event.add('dtstart').value = datetime.now() # or anything else
...

现在,如果你想通过 http 返回日历,你可以使用 cal.serialize()< /代码>。

I believe the most useful fields are:

  • dtstart: start time
  • dtend: end time
  • summary
  • location
  • url
  • description

Then you create a calendar with:

cal = vobject.iCalendar()

then an event:

event = cal.add('vevent')

and populate it:

event.add('summary').value = 'your summary'
event.add('dtstart').value = datetime.now() # or anything else
...

Now if you want to return the calendar via http, you can use cal.serialize().

影子的影子 2024-09-11 10:38:54

Outlook 2003 似乎每个 VEVENT 都需要一个 UID 字段。 icalendar 模块似乎没有使用这些,所以我不得不添加以下代码片段:

import uuid
...
event.add('uid',uuid.uuid4())

Outlook 2003 seems to need a UID field for every VEVENT. the icalendar module doesn't seem to use these, so I've had to add the following snippets of code:

import uuid
...
event.add('uid',uuid.uuid4())
一曲琵琶半遮面シ 2024-09-11 10:38:54

我在 Windows 系统上遇到了同样的问题。一旦我用 lfs 替换 crlfs ,事情就开始为我工作了。

output = cal.serialize().replace(u'\r\n', u'\n' ).strip()

I was having the same issue on a Windows system. Once I replace crlfs with lfs things started working for me.

output = cal.serialize().replace(u'\r\n', u'\n' ).strip()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文