Outlook不会将ics显示为邮件中的事件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Outlook不会将ics显示为邮件中的事件相关的知识,希望对你有一定的参考价值。

此代码将邮件发送到附加了ics存档的Outlook帐户,但Outlook不会将其识别为事件,也不会在预览中显示该事件。使用Gmail,没有任何问题。它很好地显示了预览,但Outlook似乎不兼容。我正在使用ical4j libary版本3.0.6。有人可以帮我找到问题吗?谢谢

        final String username = "example@gmail.com";
        final String password = "pass";
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "587");

        try {
            Session session = Session.getInstance(props, new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });

            // Define message
            MimeMessage message = new MimeMessage(session);
            message.addHeaderLine("method=REQUEST");
            message.addHeaderLine("charset=UTF-8");
            message.addHeaderLine("component=VEVENT");
            message.addHeaderLine("Content-Type: multipart/alternative");


            MimeMessage mimeMessage = new MimeMessage(session);
            mimeMessage.setHeader("Content-Transfer-Encoding:", "quoted-printable");
            mimeMessage.setHeader("Content-Type:", "multipart/alternative");

            Address address = new InternetAddress("example@gmail.com");
            mimeMessage.setFrom(address);
            message.addRecipients(Message.RecipientType.TO, "example@outlook.es");
            message.setSubject("Outlook Meeting Request Using JavaMail");

            StringBuffer sb = new StringBuffer();

            StringBuffer buffer = sb.append("BEGIN:VCALENDAR
" +
                    "PRODID:-//Microsoft Corporation//Outlook 9.0 
                     MIMEDIR//EN
" +
                    "VERSION:2.0
" +
                    "METHOD:REQUEST
" +
                    "TZID:Romance Standard Time
"+
                    /*"BEGIN:STANDARD
"+
                    "DTSTART:16010101T030000
"+
                    "TZOFFSETFROM:+0200
"+
                    "TZOFFSETTO:+0100
"+
                    "RRULE:FREQ=YEARLY;
                     INTERVAL=1;BYDAY=-1SU;BYMONTH=10
"+
                    "END:STANDARD
"+*/
                    "BEGIN:DAYLIGHT
"+
                    "DTSTART:16010101T020000
"+
                    "TZOFFSETFROM:+0100
"+
                    "TZOFFSETTO:+0200
"+
                    "RRULE:FREQ=YEARLY;
                     INTERVAL=1;BYDAY=-1SU;BYMONTH=3
"+
                    "END:DAYLIGHT
"+
                    "BEGIN:VEVENT
" +
                    "ATTENDEE;EXPECT=REQUIRE;
                     RSVP=YES:MAILTO:example1@outlook.es
" +
                    "ORGANIZER:MAILTO:example@gmail.com
" +
                    "DTSTART:20051208T053000Z
" +
                    "DTEND:20051208T060000Z
" +
                    "LOCATION:Conference room
" +
                    "TRANSP:1
" +
                    "SEQUENCE:0
" +
                    "LOCATION;LANGUAGE=es-ES:
"+
                    "X-MICROSOFT-CDO-APPT-SEQUENCE:0
"+
                    "X-MICROSOFT-CDO-OWNERAPPTID:2117356856
"+
                    "X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
"+
                    "X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
"+
                    "X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
"+
                    "X-MICROSOFT-CDO-IMPORTANCE:1
"+
                    "X-MICROSOFT-CDO-INSTTYPE:0
"+
                    "X-MICROSOFT-DONOTFORWARDMEETING:FALSE
"+
                    "X-MICROSOFT-DISALLOW-COUNTER:FALSE
"+
                    "X-MICROSOFT-LOCATIONS:[]
"+
                    "UID:040000008200E00074C5B7101A82E008000000000"+
                     02FF466CE3AC5010000000000000000100
" +
                    " 000004377FE5C37984842BF9440448399EB02
" +
                    "DTSTAMP:20051206T120102Z
" +
                    "CATEGORIES:Meeting
" +
                    "DESCRIPTION:This the description of the meeting
" +
                    "SUMMARY:Test meeting request
" +
                    "PRIORITY:5
" +
                    "CLASS:PUBLIC
" +
                    "BEGIN:AALARM
" +
                    "TRIGGER:PT1440M
" +
                    "ACTION:DISPLAY
" +
                    "DESCRIPTION:Reminder
" +
                    "END:AALARM
" +
                    "END:VEVENT
" +
                    "END:VCALENDAR");

            // Create the message part
            BodyPart messageBodyPart = new MimeBodyPart();

            // Fill the message
            messageBodyPart.setHeader("
            Content-Class", "urn:content-  classes:calendarmessage");
            messageBodyPart.setHeader("Content-ID", "calendar_message");
            messageBodyPart.setHeader("Content-Type", "inline");
            messageBodyPart.setHeader("filename", "prueba.ics");
            messageBodyPart.setDataHandler(new DataHandler(
                    new ByteArrayDataSource(buffer.toString(), 
            "text/calendar")));// very important

            // Create a Multipart
            Multipart multipart = new MimeMultipart();

            // Add part one
            multipart.addBodyPart(messageBodyPart);

            // Put parts in message
            message.setContent(multipart);

            // send message
            Transport.send(message);
        } catch (MessagingException me) {
            me.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
答案

使用:

内容类型:文本/日历;

以上是关于Outlook不会将ics显示为邮件中的事件的主要内容,如果未能解决你的问题,请参考以下文章

使用ics会议预约向Outlook发送电子邮件

使用 ics 会议预约向 Outlook 发送电子邮件

Outlook 2013 邀请未显示嵌入附件 - 文本/日历;方法 = 请求

使用文件资源管理器发送到 - 邮件收件人时启动的Outlook加载项

如何将列中的超链接插入Outlook电子邮件正文

Mailchimp电子邮件不会自动下载Outlook中的图像