Java Code Examples for javax.mail.internet.MimeMessage#addHeader()
The following examples show how to use
javax.mail.internet.MimeMessage#addHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportTest.java From javamail with Apache License 2.0 | 6 votes |
/** * Generate multi part / alternative message */ private MimeMessage generateMessage() throws MessagingException { MimeMessage msg = new MimeMessage(session); msg.setFrom("Test <[email protected]>"); msg.setSubject("subject"); MimeBodyPart textPart = new MimeBodyPart(); textPart.setText("Body's text (text)", "UTF-8"); MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent("<p>Body's text <strong>(html)</strong></p>", "text/html; charset=UTF-8"); Multipart multiPart = new MimeMultipart("alternative"); multiPart.addBodyPart(textPart); // first multiPart.addBodyPart(htmlPart); // second msg.setContent(multiPart); msg.addHeader("X-Custom-Header", "CustomValue"); return msg; }
Example 2
Source File: AbstractImapTestCase.java From davmail with GNU General Public License v2.0 | 5 votes |
public void appendHundredMessages() throws IOException, MessagingException { for (int i = 0; i < 100; i++) { MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("to", "testto <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.setText("Test message " + i); mimeMessage.setSubject("Test subject " + i); ByteArrayOutputStream baos = new ByteArrayOutputStream(); mimeMessage.writeTo(baos); byte[] content = baos.toByteArray(); writeLine(". APPEND testfolder (\\Seen \\Draft) {" + content.length + '}'); assertEquals("+ send literal data", readLine()); writeLine(new String(content)); assertEquals(". OK APPEND completed", readFullAnswer(".")); } }
Example 3
Source File: TestExchange2003ActiveSyncBug.java From davmail with GNU General Public License v2.0 | 5 votes |
public byte[] buildContent() throws MessagingException, IOException { MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("to", "testto <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.addHeader("cc", "testcc <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.setText("Test message "); mimeMessage.setSubject("Test subject "); ByteArrayOutputStream baos = new ByteArrayOutputStream(); mimeMessage.writeTo(baos); byte[] content = baos.toByteArray(); return content; }
Example 4
Source File: MailSender.java From iaf with Apache License 2.0 | 5 votes |
private void setHeader(Collection<Node> headers, MimeMessage msg) throws MessagingException { if (headers != null && headers.size() > 0) { for (Node headerElement : headers) { String headerName = ((Element) headerElement).getAttribute("name"); String headerValue = XmlUtils.getStringValue(((Element) headerElement)); msg.addHeader(headerName, headerValue); } } }
Example 5
Source File: SendMailAnnotationListener.java From jetstream-esper with GNU General Public License v2.0 | 5 votes |
@Override public JetstreamEvent processMetaInformation(JetstreamEvent event, StatementAnnotationInfo annotationInfo) { SendMailAnnotationMetadata anntmetadata = (SendMailAnnotationMetadata) annotationInfo.getAnnotationInfo(ANNO_KEY); properties = new Properties(); properties.setProperty("mail.smtp.host", anntmetadata.getMailServer()); Session session = Session.getInstance(properties, null); try{ MimeMessage message = new MimeMessage(session); message.addHeader("Content-type", "text/HTML; charset=UTF-8"); message.setFrom(new InternetAddress(anntmetadata.getSendFrom())); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(anntmetadata.getAlertList(), false)); String[] fieldList = anntmetadata.getEventFields().split(","); StringBuffer sb = new StringBuffer(); sb.append(anntmetadata.getMailContent()).append(".\n"); for(int i=0; i<fieldList.length;i++){ sb.append(fieldList[i]).append(": ").append(event.get(fieldList[i])).append(",\n"); } message.setText(sb.toString(), "UTF-8"); StringBuffer subject = new StringBuffer(); if(anntmetadata.getAlertSeverity() != null) subject.append(anntmetadata.getAlertSeverity()).append(" alert for Jetstream Event Type").append(event.getEventType()).append(": "); if(anntmetadata.getMailSubject() != "") subject.append(anntmetadata.getMailSubject()); message.setSubject(subject.toString(), "UTF-8"); Transport.send(message); }catch (Throwable mex) { s_logger.warn( mex.getLocalizedMessage()); } return event; }
Example 6
Source File: TestSmtp.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testSendMessageTwice() throws IOException, MessagingException, InterruptedException { Settings.setProperty("davmail.smtpCheckDuplicates", "true"); String body = "First line\r\n.\r\nSecond line\r\n"; MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("to", Settings.getProperty("davmail.to")); mimeMessage.setSubject("Test subject"); mimeMessage.setText(body); sendAndCheckMessage(mimeMessage); sendAndCheckMessage(mimeMessage); }
Example 7
Source File: MailDispatcher.java From james-project with Apache License 2.0 | 5 votes |
private void restoreHeaders(MimeMessage mimeMessage, Map<String, List<String>> savedHeaders) throws MessagingException { for (Map.Entry<String, List<String>> header: savedHeaders.entrySet()) { String name = header.getKey(); mimeMessage.removeHeader(name); for (String value: header.getValue()) { mimeMessage.addHeader(name, value); } } }
Example 8
Source File: GreenMailClient.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Sending email to the user account in the server with additional headers. * * @param subject Email subject * @throws MessagingException if the properties set to the message are not valid * @throws UserException when no such user or user is null */ public void sendMail(String subject, Map<String, String> headers) throws MessagingException, UserException { MimeMessage message = createBasicMessage(subject); for (Map.Entry<String, String> entry : headers.entrySet()) { message.addHeader(entry.getKey(), entry.getValue()); } greenMailUser.deliver(message); }
Example 9
Source File: TestSmtp.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testInvalidFrom() throws IOException, MessagingException { String body = "Test message"; MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("From", "[email protected]"); mimeMessage.addHeader("To", Settings.getProperty("davmail.to")); mimeMessage.setSubject("Test subject"); mimeMessage.setText(body); sendMessage(mimeMessage, "[email protected]", null); assertEquals("451", readLine().substring(0, 3)); }
Example 10
Source File: AbstractDavMailTestCase.java From davmail with GNU General Public License v2.0 | 5 votes |
/** * Create test MIME message * @param recipient to recipient * @return mime message * @throws MessagingException on error */ protected MimeMessage createMimeMessage(@SuppressWarnings("SameParameterValue") String recipient) throws MessagingException { MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("To", recipient); mimeMessage.setText("Test message\n"); mimeMessage.setSubject("Test subject"); return mimeMessage; }
Example 11
Source File: ExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected void convertResentHeader(MimeMessage mimeMessage, String headerName) throws MessagingException { String[] resentHeader = mimeMessage.getHeader("Resent-" + headerName); if (resentHeader != null) { mimeMessage.removeHeader("Resent-" + headerName); mimeMessage.removeHeader(headerName); for (String value : resentHeader) { mimeMessage.addHeader(headerName, value); } } }
Example 12
Source File: TestImap.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testAppendWithKeywordFlags() throws IOException, MessagingException { resetTestFolder(); MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("to", "testto <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.addHeader("cc", "testcc <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.setText("Test message "); mimeMessage.setSubject("Test subject "); ByteArrayOutputStream baos = new ByteArrayOutputStream(); mimeMessage.writeTo(baos); byte[] content = baos.toByteArray(); writeLine(". APPEND testfolder (\\Seen some_tag \\Draft $Label4) {" + content.length + '}'); assertEquals("+ send literal data", readLine()); writeLine(new String(content)); assertEquals(". OK APPEND completed", readFullAnswer(".")); writeLine(". NOOP"); assertEquals(". OK NOOP completed", readFullAnswer(".")); // fetch message uid writeLine(". UID FETCH 1:* (FLAGS)"); String messageLine = readLine(); int uidIndex = messageLine.indexOf("UID ") + 4; messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex)); assertEquals(". OK UID FETCH completed", readFullAnswer(".")); assertNotNull(messageUid); writeLine(". UID FETCH " + messageUid + " (FLAGS)"); assertEquals("* 1 FETCH (UID " + messageUid + " FLAGS (\\Seen \\Draft $label4 some_tag))", readLine()); assertEquals(". OK UID FETCH completed", readFullAnswer(".")); }
Example 13
Source File: EmailUtil.java From journaldev with MIT License | 5 votes |
/** * Utility method to send simple HTML email * @param session * @param toEmail * @param subject * @param body */ public static void sendEmail(Session session, String toEmail, String subject, String body){ try { MimeMessage msg = new MimeMessage(session); //set message headers msg.addHeader("Content-type", "text/HTML; charset=UTF-8"); msg.addHeader("format", "flowed"); msg.addHeader("Content-Transfer-Encoding", "8bit"); msg.setFrom(new InternetAddress("[email protected]", "NoReply-JD")); msg.setReplyTo(InternetAddress.parse("[email protected]", false)); msg.setSubject(subject, "UTF-8"); msg.setText(body, "UTF-8"); msg.setSentDate(new Date()); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false)); System.out.println("Message is ready"); Transport.send(msg); System.out.println("EMail Sent Successfully!!"); } catch (Exception e) { e.printStackTrace(); } }
Example 14
Source File: MimeMessageWrapperTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void wrapShouldNotThrowWhenNoBody() throws Exception { MimeMessage originalMessage = new MimeMessage(Session.getDefaultInstance(new Properties())); originalMessage.addHeader("header1", "value1"); originalMessage.addHeader("header2", "value2"); originalMessage.addHeader("header2", "value3"); MimeMessageWrapper mimeMessageWrapper = MimeMessageWrapper.wrap(originalMessage); assertThat(Collections.list(mimeMessageWrapper.getAllHeaders())) .extracting(javaxHeader -> new MimeMessageBuilder.Header(javaxHeader.getName(), javaxHeader.getValue())) .contains(new MimeMessageBuilder.Header("header1", "value1"), new MimeMessageBuilder.Header("header2", "value2"), new MimeMessageBuilder.Header("header2", "value3")); }
Example 15
Source File: MailDaemon.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
/** * sends an e-mail * * @param session session connection to the SMTP server * @param toemails list of recipient e-mails * @param subject subject (title) of the e-mail * @param body body of the e-mail * @param fromemail origin of the e-mail */ private void sendEmail(Session session, String[] toemails, String subject, String body, String fromemail) { try { MimeMessage msg = new MimeMessage(session); // set message headers msg.addHeader("Content-type", "text/HTML; charset=UTF-8"); msg.addHeader("format", "flowed"); msg.addHeader("Content-Transfer-Encoding", "8bit"); msg.setFrom(new InternetAddress(fromemail)); InternetAddress[] recipients = new InternetAddress[toemails.length]; for (int i = 0; i < toemails.length; i++) recipients[i] = new InternetAddress(toemails[i]); msg.setReplyTo(InternetAddress.parse(fromemail, false)); msg.setSubject(subject, "UTF-8"); msg.setContent(body, "text/html; charset=utf-8"); msg.setSentDate(new Date()); msg.setRecipients(Message.RecipientType.TO, recipients); logger.severe("Message is ready"); Transport.send(msg); logger.severe("EMail Sent Successfully!!"); } catch (Exception e) { throw new RuntimeException("email sending error " + e.getMessage() + " for server = server:" + this.smtpserver + " - port:" + this.port + " - user:" + this.user); } }
Example 16
Source File: TestImap.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testDraftMessageMessageId() throws IOException, MessagingException { resetTestFolder(); appendMessage(); MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("to", "testto <" + Settings.getProperty("davmail.to") + ">"); mimeMessage.setText("Test message"); mimeMessage.setSubject("Test subject"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); mimeMessage.writeTo(baos); byte[] content = baos.toByteArray(); writeLine(". APPEND testfolder (\\Seen \\Draft) {" + content.length + '}'); assertEquals("+ send literal data", readLine()); writeLine(new String(content)); assertEquals(". OK APPEND completed", readFullAnswer(".")); writeLine(". UID SEARCH UNDELETED (HEADER Message-ID " + mimeMessage.getMessageID().substring(1, mimeMessage.getMessageID().length() - 1) + ")"); assertEquals(". OK SEARCH completed", readFullAnswer(".")); writeLine(". UID SEARCH (HEADER To " + Settings.getProperty("davmail.to") + ")"); assertEquals(". OK SEARCH completed", readFullAnswer(".")); writeLine(". UID SEARCH (HEADER To testto)"); assertEquals(". OK SEARCH completed", readFullAnswer(".")); //testDeleteFolder(); }
Example 17
Source File: UpdateThread.java From ImapNote2 with GNU General Public License v3.0 | 4 votes |
public void WriteMailToNew(OneNote note, String usesticky, String noteBody) throws MessagingException, IOException { String body = null; // Here we add the new note to the "new" folder //Log.d(TAG,"Add new note"); Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); MimeMessage message = new MimeMessage(session); if (usesticky.equals("true")) { body = "BEGIN:STICKYNOTE\nCOLOR:" + this.color + "\nTEXT:" + noteBody + "\nPOSITION:0 0 0 0\nEND:STICKYNOTE"; message.setText(body); message.setHeader("Content-Transfer-Encoding", "8bit"); message.setHeader("Content-Type","text/x-stickynote; charset=\"utf-8\""); } else { message.setHeader("X-Uniform-Type-Identifier","com.apple.mail-note"); UUID uuid = UUID.randomUUID(); message.setHeader("X-Universally-Unique-Identifier", uuid.toString()); body = noteBody; body = body.replaceFirst("<p dir=ltr>", "<div>"); body = body.replaceFirst("<p dir=\"ltr\">", "<div>"); body = body.replaceAll("<p dir=ltr>", "<div><br></div><div>"); body = body.replaceAll("<p dir=\"ltr\">", "<div><br></div><div>"); body = body.replaceAll("</p>", "</div>"); body = body.replaceAll("<br>\n", "</div><div>"); message.setText(body, "utf-8", "html"); message.setFlag(Flags.Flag.SEEN,true); } message.setSubject(note.GetTitle()); MailDateFormat mailDateFormat = new MailDateFormat(); // Remove (CET) or (GMT+1) part as asked in github issue #13 String headerDate = (mailDateFormat.format(new Date())).replaceAll("\\(.*$", ""); message.addHeader("Date", headerDate); //déterminer l'uid temporaire String uid = Integer.toString(Math.abs(Integer.parseInt(note.GetUid()))); File directory = new File ((ImapNotes2.getAppContext()).getFilesDir() + "/" + Listactivity.imapNotes2Account.GetAccountname() + "/new"); //message.setFrom(new InternetAddress("ImapNotes2", Listactivity.imapNotes2Account.GetAccountname())); message.setFrom(Listactivity.imapNotes2Account.GetAccountname()); File outfile = new File (directory, uid); OutputStream str = new FileOutputStream(outfile); message.writeTo(str); }
Example 18
Source File: MimeMessageBuilder.java From james-project with Apache License 2.0 | 4 votes |
public MimeMessage build() throws MessagingException { Preconditions.checkState(!(text.isPresent() && content.isPresent()), "Can not get at the same time a text and a content"); MimeMessage mimeMessage = new MimeMessage(Session.getInstance(new Properties())); if (text.isPresent()) { mimeMessage.setContent(text.get(), textContentType.orElse(DEFAULT_TEXT_PLAIN_UTF8_TYPE)); } if (content.isPresent()) { mimeMessage.setContent(content.get()); } if (sender.isPresent()) { mimeMessage.setSender(sender.get()); } if (subject.isPresent()) { mimeMessage.setSubject(subject.get()); } ImmutableList<InternetAddress> fromAddresses = from.build(); if (!fromAddresses.isEmpty()) { mimeMessage.addFrom(fromAddresses.toArray(InternetAddress[]::new)); } List<InternetAddress> toAddresses = to.build(); if (!toAddresses.isEmpty()) { mimeMessage.setRecipients(Message.RecipientType.TO, toAddresses.toArray(InternetAddress[]::new)); } List<InternetAddress> ccAddresses = cc.build(); if (!ccAddresses.isEmpty()) { mimeMessage.setRecipients(Message.RecipientType.CC, ccAddresses.toArray(InternetAddress[]::new)); } List<InternetAddress> bccAddresses = bcc.build(); if (!bccAddresses.isEmpty()) { mimeMessage.setRecipients(Message.RecipientType.BCC, bccAddresses.toArray(InternetAddress[]::new)); } MimeMessage wrappedMessage = MimeMessageWrapper.wrap(mimeMessage); List<Header> headerList = headers.build(); for (Header header: headerList) { if (header.name.equals("Message-ID") || header.name.equals("Date")) { wrappedMessage.setHeader(header.name, header.value); } else { wrappedMessage.addHeader(header.name, header.value); } } wrappedMessage.saveChanges(); return wrappedMessage; }
Example 19
Source File: EwsExchangeSession.java From davmail with GNU General Public License v2.0 | 4 votes |
/** * Get item content. * * @param itemId EWS item id * @return item content as byte array * @throws IOException on error */ protected byte[] getContent(ItemId itemId) throws IOException { GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true); byte[] mimeContent = null; try { executeMethod(getItemMethod); mimeContent = getItemMethod.getMimeContent(); } catch (EWSException e) { LOGGER.warn("GetItem with MimeContent failed: " + e.getMessage()); } if (getItemMethod.getStatusCode() == HttpStatus.SC_NOT_FOUND) { throw new HttpNotFoundException("Item " + itemId + " not found"); } if (mimeContent == null) { LOGGER.warn("MimeContent not available, trying to rebuild from properties"); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, false); getItemMethod.addAdditionalProperty(Field.get("contentclass")); getItemMethod.addAdditionalProperty(Field.get("message-id")); getItemMethod.addAdditionalProperty(Field.get("from")); getItemMethod.addAdditionalProperty(Field.get("to")); getItemMethod.addAdditionalProperty(Field.get("cc")); getItemMethod.addAdditionalProperty(Field.get("subject")); getItemMethod.addAdditionalProperty(Field.get("date")); getItemMethod.addAdditionalProperty(Field.get("body")); executeMethod(getItemMethod); EWSMethod.Item item = getItemMethod.getResponseItem(); if (item == null) { throw new HttpNotFoundException("Item " + itemId + " not found"); } MimeMessage mimeMessage = new MimeMessage((Session) null); mimeMessage.addHeader("Content-class", item.get(Field.get("contentclass").getResponseName())); mimeMessage.setSentDate(parseDateFromExchange(item.get(Field.get("date").getResponseName()))); mimeMessage.addHeader("From", item.get(Field.get("from").getResponseName())); mimeMessage.addHeader("To", item.get(Field.get("to").getResponseName())); mimeMessage.addHeader("Cc", item.get(Field.get("cc").getResponseName())); mimeMessage.setSubject(item.get(Field.get("subject").getResponseName())); String propertyValue = item.get(Field.get("body").getResponseName()); if (propertyValue == null) { propertyValue = ""; } mimeMessage.setContent(propertyValue, "text/html; charset=UTF-8"); mimeMessage.writeTo(baos); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Rebuilt message content: " + new String(baos.toByteArray(), StandardCharsets.UTF_8)); } mimeContent = baos.toByteArray(); } catch (IOException | MessagingException e2) { LOGGER.warn(e2); } if (mimeContent == null) { throw new IOException("GetItem returned null MimeContent"); } } return mimeContent; }
Example 20
Source File: MailDaemon.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
/** * sends invitation * * @param session session connection to the SMTP server * @param toemails list of recipient e-mails * @param subject invitation subject * @param body invitation start * @param fromemail user sending the invitation * @param startdate start date of the invitation * @param enddate end date of the invitation * @param location location of the invitation * @param uid unique id * @param cancelation true if this is a cancelation */ private void sendInvitation(Session session, String[] toemails, String subject, String body, String fromemail, Date startdate, Date enddate, String location, String uid, boolean cancelation) { try { // prepare mail mime message MimetypesFileTypeMap mimetypes = (MimetypesFileTypeMap) MimetypesFileTypeMap.getDefaultFileTypeMap(); mimetypes.addMimeTypes("text/calendar ics ICS"); // register the handling of text/calendar mime type MailcapCommandMap mailcap = (MailcapCommandMap) MailcapCommandMap.getDefaultCommandMap(); mailcap.addMailcap("text/calendar;; x-java-content-handler=com.sun.mail.handlers.text_plain"); MimeMessage msg = new MimeMessage(session); // set message headers msg.addHeader("Content-type", "text/HTML; charset=UTF-8"); msg.addHeader("format", "flowed"); msg.addHeader("Content-Transfer-Encoding", "8bit"); InternetAddress fromemailaddress = new InternetAddress(fromemail); msg.setFrom(fromemailaddress); msg.setReplyTo(InternetAddress.parse(fromemail, false)); msg.setSubject(subject, "UTF-8"); msg.setSentDate(new Date()); // set recipient InternetAddress[] recipients = new InternetAddress[toemails.length + 1]; String attendeesinvcalendar = ""; for (int i = 0; i < toemails.length; i++) { recipients[i] = new InternetAddress(toemails[i]); attendeesinvcalendar += "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:" + toemails[i] + "\n"; } recipients[toemails.length] = fromemailaddress; msg.setRecipients(Message.RecipientType.TO, recipients); Multipart multipart = new MimeMultipart("alternative"); // set body MimeBodyPart descriptionPart = new MimeBodyPart(); descriptionPart.setContent(body, "text/html; charset=utf-8"); multipart.addBodyPart(descriptionPart); // set invitation BodyPart calendarPart = new MimeBodyPart(); String method = "METHOD:REQUEST\n"; if (cancelation) method = "METHOD:CANCEL\n"; String calendarContent = "BEGIN:VCALENDAR\n" + method + "PRODID: BCP - Meeting\n" + "VERSION:2.0\n" + "BEGIN:VEVENT\n" + "DTSTAMP:" + iCalendarDateFormat.format(new Date()) + "\n" + "DTSTART:" + iCalendarDateFormat.format(startdate) + "\n" + "DTEND:" + iCalendarDateFormat.format(enddate) + "\n" + "SUMMARY:" + subject + "\n" + "UID:" + uid + "\n" + attendeesinvcalendar + "ORGANIZER:MAILTO:" + fromemail + "\n" + "LOCATION:" + location + "\n" + "DESCRIPTION:" + subject + "\n" + "SEQUENCE:0\n" + "PRIORITY:5\n" + "CLASS:PUBLIC\n" + "STATUS:CONFIRMED\n" + "TRANSP:OPAQUE\n" + "BEGIN:VALARM\n" + "ACTION:DISPLAY\n" + "DESCRIPTION:REMINDER\n" + "TRIGGER;RELATED=START:-PT00H15M00S\n" + "END:VALARM\n" + "END:VEVENT\n" + "END:VCALENDAR"; calendarPart.addHeader("Content-Class", "urn:content-classes:calendarmessage"); calendarPart.setContent(calendarContent, "text/calendar;method=CANCEL"); multipart.addBodyPart(calendarPart); msg.setContent(multipart); logger.severe("Invitation is ready"); Transport.send(msg); logger.severe("EMail Invitation Sent Successfully!! to " + attendeesinvcalendar); } catch (Exception e) { logger.severe( "--- Exception in sending invitation --- " + e.getClass().toString() + " - " + e.getMessage()); if (e.getCause() != null) logger.severe(" cause " + e.getCause().getClass().toString() + " - " + e.getCause().getMessage()); throw new RuntimeException("email sending error " + e.getMessage() + " for server = server:" + this.smtpserver + " - port:" + this.port + " - user:" + this.user); } }