你好,我是一个新手,想要在Java中手动解析ICS(Outlook日历文件)。如何不使用第三方API来解析ICS文件?
你好,我是一个新手,想要在Java中手动解析ICS(Outlook日历文件)。如何不使用第三方API来解析ICS文件?
{
Properties prop = new Properties();
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.host", "smtp.gmail.com");
prop.put("mail.smtp.port", "587");
final String username = "xx@xx"; //your email id
final String password = "password"; //your password
System.out.println(meeting);
try {
Session session = Session.getInstance(prop, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
MimeMessage mimeMessage = new MimeMessage(session);
Multipart multipart = new MimeMultipart("alternative");
if (calendar != null) {
// Another part for the calendar invite
MimeBodyPart invite = new MimeBodyPart();
invite.setHeader("Content-Class", "urn:content- classes:calendarmessage");
invite.setHeader("Content-ID", "calendar_message");
invite.setHeader("Content-Disposition", "inline");
invite.setContent(calendar.toString(), "text/calendar");
multipart.addBodyPart(invite);
}
mimeMessage.setContent(multipart);
Transport.send(mimeMessage);
}