我正在使用 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," + "nn No spam to my email, please!");
Transport.send(message);
我正在尝试这样的事情
message.setContent(meeting, "MyMeeting");
但它的投掷例外。知道我该怎么做吗?
这是一个解决方案
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);
}