Currently i have a problem when send the email with content type is multipart. I don't use Email script to send, i use Java mail to do because i have to add a ICS file content(invitation calendar file) to email header. Actually it can work perfectly if i create a main() in ivy and send it but if i called it by ivy script, it always throw error:
 UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
        boundary="----=_Part_22_936261044.1395656648093"
    MessagingException: IOException while sending message
    IvyScriptMethodInvocationException: Error calling method sendMail(net.fortuna.ical4j.model.Calendar) on an object of class ch.ivyteam.ivy.scripting.internal.language.StaticAccess. Reason: javax.mail.MessagingException: IOException while sending message;
      nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
        boundary="----=_Part_22_936261044.1395656648093"
    IvyScriptRuntimeException: IvyScript Runtime Exception in
        Instruction:
            ch.soreco.customers.xabs.util.CalendarUtil.sendMail()
Below code is used for sending email:
Session session = Session.getInstance(properties, authenticator);
        transport = session.getTransport();
        transport.connect(username, password);
        // register the text/calendar mime type
        MimetypesFileTypeMap mimetypes = (MimetypesFileTypeMap) MimetypesFileTypeMap.getDefaultFileTypeMap();
        mimetypes.addMimeTypes("text/calendar ics ICS");
        //register the handling of text/calendar mime type
        MailcapCommandMap mailcap = (MailcapCommandMap) MailcapCommandMap.getDefaultCommandMap();
        mailcap.addMailcap("text/calendar;; x-java-content-handler=com.sun.mail.handlers.text_plain");
        mailcap.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); 
        mailcap.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); 
        mailcap.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); 
        mailcap.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true"); 
        mailcap.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); 
        CommandMap.setDefaultCommandMap(mailcap);
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.setSubject(subject);
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setHeader("X-Mailer", "iQuest-Mailer");
        // Create an alternative Multipart
        Multipart multipart = new MimeMultipart("mixed");
        MimeBodyPart descriptionPart = new MimeBodyPart();
   String content = "simple meeting invitation.";
        descriptionPart.setContent(content, "text/html; charset=utf-8");
        BodyPart messageBodyPart = descriptionPart;
        multipart.addBodyPart(messageBodyPart);
        // Add part two, the calendar
        String calString = "BEGIN:VCALENDAR\n" +
                "PRODID:-//XpertIvy//iCal4j 1.0//XABS\n" +
                "VERSION:2.0\n" +
                "CALSCALE:GREGORIAN\n" +
                "METHOD:PUBLISH\n" +
                "BEGIN:VEVENT\n" +
                "DTSTAMP:20140321T033611Z\n" +
                "DTSTART;VALUE=DATE:20140323\n" +
                "DTEND;VALUE=DATE:20140324\n" +
                "UID:xpert.abs-recurrence-0\n" +
                "ORGANIZER:noreply@soreco.ch\n" +
                "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=cavoirom@gmail.com:MAILTO:cavoirom@gmail.com\n" +
                "X-MICROSOFT-CDO-BUSYSTATUS:OOF\n" +
                "RRULE:FREQ=WEEKLY;COUNT=2;INTERVAL=1;BYDAY=MO,SU\n" +
                "DESCRIPTION:VINH weekly 21.3\n" +
                "SUMMARY:Fatality: Partner\\, Child\\, Parent\n" +
                "EXDATE:20140322\n" +
                "END:VEVENT\n" +
                "END:VCALENDAR\n";
        BodyPart calendarPart = new MimeBodyPart();
        calendarPart.addHeader("Content-Class", "urn:content-classes:calendarmessage");
        calendarPart.setHeader("Content-ID","calendar_message");
        calendarPart.setContent(calString, "text/calendar; charset=\"utf-8\"; method=REQUEST");
        multipart.addBodyPart(calendarPart);
        //Put the multipart in message 
        message.setContent(multipart);
        Transport.send(message);
        transport.close();
Ivy version: 5.04
Javamail verion: 1.4.4
Anyone can help me?
                             
                            
                                
                                
                            
                            
                                    
    
        asked
        24.03.2014 at 11:29
    
    
    trungdv
    (suspended)
    
    accept rate:
    52%