问题
So,I'm sending ICal invitations with Java Mail,I give each of them a Message-ID.
Now if someone replies by accepting/declining, I get a reply email,but with a different Message-ID.
It seems Outlook generates new Message-IDs and throws away every header I've set in the invitation, is there any way to match the sent invitation to their replies or the other way around?
Here is what it shows when I look up my internet header of the invitation:
Return-Path:
X-Original-To:
Delivered-To:
Received: from
by
for ; Tue, 15 Oct 2013 09:52:39 +0200 (CEST)
From:
To:
Message-ID: 11111111111111111111111111
Subject: TestMail
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_0_694990101.1381823559402"
UID: 114442
ContentID: blabla
And here is what the header of the reply looks like:
Return-Path:
X-Original-To:
Delivered-To:
Received: from
for ; Tue, 15 Oct 2013 09:52:44 +0200 (CEST)
From:
To:
Subject: Accepted: TestMail 11.10
Date: Tue, 15 Oct 2013 09:52:44 +0200
Message-ID: <000301cec97b$8866c540$99344fc0$@do@me.com>
MIME-Version: 1.0
Content-Type: text/calendar; method=REPLY;
charset="utf-8"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Ac7Je4UCPB4Lb2ZERnCPQEx3IbfpbQAAAEBQAAAAkSA=
Content-Language: de
Thanks for any help in advance!
回答1:
If the reply includes the original subject, you can put something in the subject header. You could also consider generating unique reply addresses for each invitation. Possibly there's a unique identifier you can put in the invitation itself that will be included in the response.
回答2:
Well the iCalendar UID property was defined exactly for this purpose. See http://tools.ietf.org/html/rfc5545#section-3.8.4.7
Each reply should contain a UID property (inside the VEVENT component) matching the value from your original request. You should not rely on the Transport mechanism (iMIP here but it could be iSchedule) to do the matching.
回答3:
I had a similar problem when I used Amazon SES as my SMTP server, It over-rode my Javamail Message-ID and replaced it with its own. A short and simple solution would be to send a randomly generated UID in the reference header ( Reference header is not usually over-written by most Email service providers) :-
Something like this : email.setHeader("References", reference);
where reference header is like this : reference = UUID.randomUUID().toString()+"@email.abcd.com"
For more detail on Reference header, see this : http://cr.yp.to/immhf/thread.html
回答4:
I got it! I needed to read the body of the reply and not the header. Everything I have set was stored in the body. To get the content of the body you have to get the inputStream, like this:
Folder folder = store.getFolder("Inbox");
folder.open(Folder.READ_WRITE);
Message message[] = folder.getMessages();
InputStream in = messages.getInputStream();
Then you just have to write a typical IO Reader to get the lines,split it and take the values you have set.That's it.
来源:https://stackoverflow.com/questions/19320086/how-to-match-replied-emails-to-the-sent-invitationsjava-mail