Question

I am using Ical4j API to send meeting invitation from my gmail id but how to set

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

VEvent object to the mail API class

    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);

I was trying something like this

message.setContent(meeting, "MyMeeting");

But its throwing exception.Any Idea how can i do it?

Was it helpful?

Solution

Here is the one solution for this

             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);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top