3

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("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();
}

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 <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

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

Update 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
ghost23
  • 2,150
  • 1
  • 20
  • 35
  • sorry for being too fuzzy, updated my explanation. – ghost23 Sep 13 '11 at 13:31
  • You're still not including your full code. Is that snippet the entire message you construct and send, or just the attachment part? You need to include all the code relevant to sending the email, and a copy of the log entries and output email message from the logs. – Nick Johnson Sep 13 '11 at 23:35
  • While writing this, i realize, that my initial explanation was completely misleading. I do not want to send the iCalendar as an attachment, but directly in the body, because only this way, MS Outlook shows the mail directly as a meeting invitation. – ghost23 Sep 14 '11 at 10:09
  • Hm. This could be a bug in the dev appserver. Have you tried deploying it and examining the message you get? – Nick Johnson Sep 15 '11 at 00:20
  • not yet, but will try it today. – ghost23 Sep 15 '11 at 09:23
  • ok, tried and yes, it is the same on the production side. – ghost23 Sep 15 '11 at 10:57
  • Can you include the raw body of the email you get in your question? – Nick Johnson Sep 15 '11 at 12:58
  • oh my, why does Message have no easy way do dump as a string. done. – ghost23 Sep 15 '11 at 14:52
  • I have the same problen. please help me out – Nuwan Jan 26 '12 at 06:58

1 Answers1

0

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

(not affiliated !)

koma
  • 6,486
  • 2
  • 27
  • 53