0

我正在使用Ical4j API 从我的 gmail id 发送会议邀请,但如何设置

VEvent meeting = new VEvent(startDt, dur, subject);

VEvent反对邮件 API 类

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("myemail82@gmail.com"));
    message.setRecipients(Message.RecipientType.TO,    InternetAddress.parse("recepent@gmail.com"));
    message.setSubject("Testing Subject");
    message.setText("Dear Mail Crawler," + "\n\n No spam to my email, please!");
    Transport.send(message);

我正在尝试这样的事情

message.setContent(meeting, "MyMeeting");

但它抛出异常。任何想法我该怎么做?

4

1 回答 1

2

这是解决此问题的一种方法

             try {
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress("sender@emailID.com"));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress("recepint@emailID.com"));
        message.setSubject("Hello iCal4j Meeting Invitation");

        // create the message part
        MimeBodyPart messageBodyPart = new MimeBodyPart();

        // fill message
        messageBodyPart.setText("Hi Sir, Please see the demo example to send meeting invitaiton from iCal4j API.");

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);

        // Part two is attachment
        messageBodyPart = new MimeBodyPart();
        DataSource source = new FileDataSource(calFile);
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setFileName(calFile);
        multipart.addBodyPart(messageBodyPart);

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

        Transport.send(message);
    //  System.out.println(meeting);

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
于 2013-09-10T11:19:56.813 回答