通过 Google 应用引擎发送会议邀请邮件

发布于 2024-12-03 14:40:42 字数 6222 浏览 5 评论 0原文

我想发送 iCalendar 会议邀请。我正在使用谷歌应用程序引擎,Java。 我设法发送带有 iCalendar 文件作为附件的邮件,但 Outlook 等程序不会自动将其识别为会议邀请。

我想,我必须将附件的内容类型 设置为:“text/calendar; method=REQUEST”,但在我看来,GAE 不接受这一点?

更新:我上面错了。我实际上发现,我必须直接在内容中发送包含 iCalendar 部分的邮件,而不是作为附件!所以我的问题是,GAE 似乎不接受设置消息本身的内容类型。

有人使用 GAE 通过邮件成功发送会议邀请 iCalendar 元素吗?

更新:

我明白,我必须更具体。事实上,我想发送 iMip 消息。 iMip 消息不是多部分的,其内容类型是“文本/日历”。如果发送会议邀请,则为“text/calendar;method=REQUEST”。所以我尝试了这个:

Message msg = new MimeMessage(session);
msg.setContent(iCalendarAsString, "text/calendar;method=REQUEST");

然后我用 Transport.send(..); 发送消息

在 GAE 开发服务器的日志中,我看到内容类型是“text/plain”。 这就是为什么我说,我认为 GAE 不接受设置不同的内容类型。

还是我错了?

更新2

好的,这是完整的代码:

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);


try {
    Message msg = new MimeMessage(session);

    msg.setFrom(new InternetAddress("[email protected]", "SomeApp"));
    msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress("[email protected]", "Sven Busse"));
    msg.setSubject("meeting invitation!");
    msg.setContent(iCalendarAsString, "text/calendar;method=REQUEST");

    Transport.send(msg);

} catch (AddressException e) {
    log.warning(e.toString());
    e.printStackTrace();
} catch (MessagingException e) {
    log.warning(e.toString());
    e.printStackTrace();
} catch (UnsupportedEncodingException e) {
    log.warning(e.toString());
    e.printStackTrace();
}

因此,我将内容类型设置为“text/calendar;method=REQUEST”。一旦我发送,这就是日志:

14.09.2011 09:52:59 com.google.appengine.api.mail.dev.LocalMailService log
INFO: MailService.send
INFO:   From: SomeApp <[email protected]>
INFO:   To: Sven Busse <[email protected]>
INFO:   Reply-to: SomeApp <[email protected]>
INFO:   Subject: meeting invitation!
INFO:   Body:
INFO:     Content-type: text/plain
INFO:     Data length: 458

所以,日志看起来不太漂亮,但你可以看到,内容类型已更改为“文本/纯文本”。

更新3:

Delivered-To: [email protected]
Received: by 10.68.59.7 with SMTP id v7cs112540pbq;
        Thu, 15 Sep 2011 07:45:55 -0700 (PDT)
Received: by 10.52.95.44 with SMTP id dh12mr1121151vdb.20.1316097954738;
        Thu, 15 Sep 2011 07:45:54 -0700 (PDT)
Return-Path: <3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com>
Received: from mail-vw0-f69.google.com (mail-vw0-f69.google.com [209.85.212.69])
        by mx.google.com with ESMTPS id o9si1579035vcv.136.2011.09.15.07.45.53
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 15 Sep 2011 07:45:53 -0700 (PDT)
Received-SPF: pass (google.com: domain of 3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.69 as permitted sender) client-ip=209.85.212.69;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of 3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.69 as permitted sender) smtp.mail=3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com
Received: by vws20 with SMTP id 20so3831617vws.4
        for <[email protected]>; Thu, 15 Sep 2011 07:45:53 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.236.187.1 with SMTP id x1mr5481998yhm.8.1316097953249; Thu, 15
 Sep 2011 07:45:53 -0700 (PDT)
Reply-To: SomeApp <[email protected]>
X-Google-Appengine-App-Id: someapp
Message-ID: <[email protected]>
Date: Thu, 15 Sep 2011 14:45:53 +0000
Subject: meeting invitation!
From: SomeApp <[email protected]>
To: Sven Busse <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

BEGIN:VCALENDAR
PRODID:-//Ben Fortuna//iCal4j 1.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20110915T144552Z
UID:[email protected]
SUMMARY:tolles projekt\, macht viel spass.
DTSTART;VALUE=DATE:20110919
DTEND;VALUE=DATE:20110926
DESCRIPTION:tolles projekt\, macht viel spass.
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
END:VCALENDAR

i want to send iCalendar meeting invitations. I am using Google App engine, Java.
I managed to send a mail with an iCalendar file as an attachment, but programs like Outlook do not automatically recognize it as a meeting invitation.

I figure, i have to set the content-type of the attachment to: "text/calendar; method=REQUEST", but it seems to me, GAE is not accepting this?

Update: I was wrong above. I actually found, that i have to send the mail with the iCalendar part directly in the content, not as an attachment! So my problem is, GAE seems not to accept setting the content-type of the message itself.

Has anyone succesfully send a meeting invitation iCalendar element through mail using GAE?

Update:

I understand, i have to be more specific. In fact, i want to send iMip messages. iMip messages are not multipart, their content-type is "text/calendar". And in the case of sending a meeting invitation, it would be "text/calendar;method=REQUEST". So i tried this:

Message msg = new MimeMessage(session);
msg.setContent(iCalendarAsString, "text/calendar;method=REQUEST");

Then i send the message with Transport.send(..);

In the logs in the development server of GAE i then see, that the content type is "text/plain".
that's why i said, i think, GAE is not accepting setting a different content type.

Or am i wrong?

Update 2

OK, here's the complete code:

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);


try {
    Message msg = new MimeMessage(session);

    msg.setFrom(new InternetAddress("[email protected]", "SomeApp"));
    msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress("[email protected]", "Sven Busse"));
    msg.setSubject("meeting invitation!");
    msg.setContent(iCalendarAsString, "text/calendar;method=REQUEST");

    Transport.send(msg);

} catch (AddressException e) {
    log.warning(e.toString());
    e.printStackTrace();
} catch (MessagingException e) {
    log.warning(e.toString());
    e.printStackTrace();
} catch (UnsupportedEncodingException e) {
    log.warning(e.toString());
    e.printStackTrace();
}

So, i set the content-type to "text/calendar;method=REQUEST". And once i send, this is the logs:

14.09.2011 09:52:59 com.google.appengine.api.mail.dev.LocalMailService log
INFO: MailService.send
INFO:   From: SomeApp <[email protected]>
INFO:   To: Sven Busse <[email protected]>
INFO:   Reply-to: SomeApp <[email protected]>
INFO:   Subject: meeting invitation!
INFO:   Body:
INFO:     Content-type: text/plain
INFO:     Data length: 458

So, the logs don't look pretty, but you can see, the content-type has changed to "text/plain".

Update 3:

Delivered-To: [email protected]
Received: by 10.68.59.7 with SMTP id v7cs112540pbq;
        Thu, 15 Sep 2011 07:45:55 -0700 (PDT)
Received: by 10.52.95.44 with SMTP id dh12mr1121151vdb.20.1316097954738;
        Thu, 15 Sep 2011 07:45:54 -0700 (PDT)
Return-Path: <3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com>
Received: from mail-vw0-f69.google.com (mail-vw0-f69.google.com [209.85.212.69])
        by mx.google.com with ESMTPS id o9si1579035vcv.136.2011.09.15.07.45.53
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 15 Sep 2011 07:45:53 -0700 (PDT)
Received-SPF: pass (google.com: domain of 3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.69 as permitted sender) client-ip=209.85.212.69;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of 3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.69 as permitted sender) smtp.mail=3oQ9yTgoJCgIdqqmngvqpciockn.eqouxgp.dwuugiqqingockn.eqo@2uix4h7xygsz66weerlq.apphosting.bounces.google.com
Received: by vws20 with SMTP id 20so3831617vws.4
        for <[email protected]>; Thu, 15 Sep 2011 07:45:53 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.236.187.1 with SMTP id x1mr5481998yhm.8.1316097953249; Thu, 15
 Sep 2011 07:45:53 -0700 (PDT)
Reply-To: SomeApp <[email protected]>
X-Google-Appengine-App-Id: someapp
Message-ID: <[email protected]>
Date: Thu, 15 Sep 2011 14:45:53 +0000
Subject: meeting invitation!
From: SomeApp <[email protected]>
To: Sven Busse <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

BEGIN:VCALENDAR
PRODID:-//Ben Fortuna//iCal4j 1.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20110915T144552Z
UID:[email protected]
SUMMARY:tolles projekt\, macht viel spass.
DTSTART;VALUE=DATE:20110919
DTEND;VALUE=DATE:20110926
DESCRIPTION:tolles projekt\, macht viel spass.
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
END:VCALENDAR

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

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

发布评论

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

评论(1

苦行僧 2024-12-10 14:40:42

也许您应该考虑使用像 http://context.io/ 这样的服务?

(不隶属!)

Maybe you should think of using a service like http://context.io/ ?

(not affiliated !)

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