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