0
我已經做了一個.ics
文件發送從org.apache.commons.mail.MultiPartEmail
但結果是不同的每個電子郵件服務器;用java電子郵件發送日曆事件
實施例:
當發送到G-郵件地址,接收器識別該文件.ics
像一個事件,並示出了在郵件正文中的事件的詳細信息。
在雅虎,它標識事件,但不顯示細節。
在Microsoft郵件服務器(hotmail,outlook)中,.ics
文件在郵件正文中顯示爲明文,並且不會被識別爲事件。
我真的不知道如何讓Microsoft郵件服務器識別事件並顯示詳細信息以及要在日曆中添加的按鈕。
這是.ics
代碼:
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
PRODID:LBstation
BEGIN:VEVENT
UID:1e89d5a5-09c3-477c-9dd7-b9af39e514b2
DTSTAMP:20160506T143307Z
SUMMARY:Test ICS
DTSTART:20160529T130000Z
DTEND:20160529T140000Z
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;ROLE=ATTENDEE;CN=Leonardo Outlook:mailto:[email protected]
ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;RSVP=TRUE;ROLE=ORGANIZER;CN=Leonardo Peixoto:mailto:[email protected]
SEQUENCE:0
ORGANIZER;CN=Leonardo Bruno Peixoto:mailto:[email protected]
CREATED:20160506T143307Z
LAST-MODIFIED:20160506T143307Z
DESCRIPTION:Test ics
TRANSP:OPAQUE
STATUS:CONFIRMED
LOCATION:
END:VEVENT
END:VCALENDAR
這是代碼:
MimeMultipart mmp = new MimeMultipart("mixed");
MimeMultipart mmpa = new MimeMultipart("alternative");
MimeBodyPart plainPart = new MimeBodyPart();
plainPart.setHeader("Content-Type", "text/plain; charset=UTF-8; format=flowed; delsp=yes");
plainPart.setHeader("Content-Transfer-Encoding", "base64");
ByteArrayDataSource dsPlain = new ByteArrayDataSource("","text/plain;method=REQUEST");
DataHandler dhPlain = new DataHandler(dsPlain);
plainPart.setDataHandler(dhPlain);
mmpa.addBodyPart(plainPart);
MimeBodyPart calendarPart = new MimeBodyPart();
calendarPart.setHeader("Content-Type", "text/calendar; charset=UTF-8; method=REQUEST");
calendarPart.setHeader("Content-Transfer-Encoding", "7bit");
ByteArrayDataSource dsCalendario = new ByteArrayDataSource(str,"text/calendar;method=REQUEST");
DataHandler dhCalendario = new DataHandler(dsCalendario);
calendarPart.setDataHandler(dhCalendario);
mmpa.addBodyPart(calendarPart);
MimeBodyPart htmlAndTextBodyPart = new MimeBodyPart();
htmlAndTextBodyPart.setContent(mmpa);
mmp.addBodyPart(htmlAndTextBodyPart);
email.addPart(mmp);
顯示相關代碼。 – gfelisberto