gpt4 book ai didi

java - 通过 Google 应用引擎发送 session 邀请邮件

转载 作者:行者123 更新时间:2023-12-02 09:46:41 25 4
gpt4 key购买 nike

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

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

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

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

更新:

我明白了,我必须说得更具体。事实上,我想发送 iMip 消息。 iMip 消息不是多部分的,其内容类型是“文本/日历”。如果发送 session 邀请,则为“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("ical@someapp.appspotmail.com", "SomeApp"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("me@mydomain.de", "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 <ical@someapp.appspotmail.com>
INFO: To: Sven Busse <me@mydomain.de>
INFO: Reply-to: SomeApp <ical@someapp.appspotmail.com>
INFO: Subject: meeting invitation!
INFO: Body:
INFO: Content-type: text/plain
INFO: Data length: 458

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

更新3:

Delivered-To: me@mydomain.de
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 <me@mydomain.de>; 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 <ical@someapp.appspotmail.com>
X-Google-Appengine-App-Id: someapp
Message-ID: <20cf305e2551fe38a104acfbee28@google.com>
Date: Thu, 15 Sep 2011 14:45:53 +0000
Subject: meeting invitation!
From: SomeApp <ical@someapp.appspotmail.com>
To: Sven Busse <me@mydomain.de>
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:20110915T144552Z-1@someapp.appspotmail.com
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:me@mydomain.de
ORGANIZER:mailto:ical@someapp.appspotmail.com
END:VEVENT
END:VCALENDAR

最佳答案

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

(不隶属!)

关于java - 通过 Google 应用引擎发送 session 邀请邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7359474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com