new InternetAddress( userInfo.getEmailForEntity( owner ) ) );
message.setSubject( "Task Assignment " + type + " Event: " + name );
message.setSentDate( new Date() );
// Create a Multipart
Multipart multipart = new MimeMultipart( "alternative" );
// Add text message
BodyPart messageBodyPart = new MimeBodyPart();
String text = "Summary\n-------\n\n" + summary + "\n\nDescription\n-----------\n\n" + description;
messageBodyPart.setText( text );
messageBodyPart.setDataHandler( new DataHandler( new ByteArrayDataSource( text,
"text/plain; charset=UTF8;" ) ) );
multipart.addBodyPart( messageBodyPart );
// Add ical
messageBodyPart = new MimeBodyPart();
String filename = "ical-" + type + "-" + taskId + ".ics";
messageBodyPart.setFileName( filename );
messageBodyPart.setHeader( "Content-Class",
"urn:content-classes:calendarmessage" );
messageBodyPart.setHeader( "Content-ID",
"calendar_message" );
String icalStr = getIcal( summary,
description,
startDate,
priority,
userInfo.getDisplayName( creator ),
creatorEmail,
type );
messageBodyPart.setDataHandler( new DataHandler( new ByteArrayDataSource( icalStr,
"text/calendar; charset=UTF8; " ) ) );
multipart.addBodyPart( messageBodyPart );
message.setContent( multipart );
message.saveChanges();
Transport.send( message );