In my project, we usually don’t send mails directly, rather we create a mail file that the user downloads, opens using Outlook (and potentially modifies) and then sends themselves from their Outlook. This works for normal mails, my code for that looks like this:
MailMessage msg = new MailMessage();
MailAddressCollection recipient = new MailAddressCollection();
recipient.add(emailDataSource.getTo());
msg.setTo(recipient);
msg.setSubject(emailDataSource.getSubject());
msg.setHtmlBody(templateSource.getText());
...
File resultEmail = File.createTempFile("TEMPLATE_MAIL_", ".eml");
resultEmail.deleteOnExit();
FileOutputStream fs = new FileOutputStream(resultEmail);
message.save(fs);
fs.close();
InputStream stream = new FileInputStream(resultEmail);
String contentType = FacesContext.getCurrentInstance().getExternalContext().getMimeType(resultEmail.getPath());
return new DefaultStreamedContent(stream, contentType, resultEmail.getPath());
This creates an email where things like the subject and recipients are already filled out, so the user can send it after opening it. Now I would like to do the same thing, but include a Meeting. I found that you can add an Appointmant to a mail like this:
Appointment app = new Appointment(
"Location", // location of meeting
startDate, // start date
endDate, // end date
new MailAddress("organizer@domain.com"), // organizer
attendees); // attendees
msg.addAlternateView(app.requestApointment());
When I do it like that and open the resulting file, it displays the Appointment for the user that opening the file, with no way of sending it to the recipient specified in the code. How can I make it so that opening the file results in the user being presented the Outlook Meeting interface which enables the user to send the appointment to other people? Like this:
Screenshot 2023-04-20 102240.png (30.3 KB)