Package org.jdesktop.jdic.desktop

Examples of org.jdesktop.jdic.desktop.Message


    public static void sendMailWithAttachmentDesktop(final String toMail,
            final String subject, final String message,
            final String pathToAttachment) throws ProTransException {
        try {
            //init();
            Message msg = new Message();
            msg.setToAddrs(getToList(toMail));
            msg.setSubject(subject);
            msg.setBody(message);

            List<String> attachList = new ArrayList<String>();
            attachList.add(pathToAttachment);
            msg.setAttachments(attachList);
            Desktop.mail(msg);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ProTransException(e);
        }
View Full Code Here


  }
 
  public boolean mailFiles(String to, String subject, String body, String[] attachmentFiles)
  {
    Message message=new Message();
    ArrayList toAddresses=new ArrayList();
    toAddresses.add(to);
    message.setToAddrs(toAddresses);
    message.setSubject(subject);
   
    ArrayList attachmentList = new ArrayList();
    for (int i=0; i<attachmentFiles.length; i++)
      attachmentList.add(attachmentFiles[i]);
   
    try {
      message.setAttachments(attachmentList);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      JOptionPane.showMessageDialog(
          null,
          "Cannot add attachments! " + e.getMessage(),
          "Email not sent",
          JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
      return false;
    }
   
    message.setBody(body);
    try {
      Desktop.mail(message);
      return true;
    } catch (DesktopException ex) {
      ex.printStackTrace();
View Full Code Here

                    MessageSourceAccessor.class);
        }
    }

    public void reportError(ErrorInfo info) {
        Message mail = new Message();

        String mailTo = getMessageByKeySuffix(".mailTo");
        if (!StringUtils.isEmpty(mailTo)) {
            boolean doOutlookWorkaround = false;
            if (outlookWorkaroundEnabled) {
                boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
                if (isWindows) {
                    doOutlookWorkaround = JOptionPane.showConfirmDialog(null,
                            getMessageByKeySuffix(".isOutlook.message"),
                            getMessageByKeySuffix(".isOutlook.title"),
                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)
                            == JOptionPane.YES_OPTION;
                }
            }
            String[] mailToTokens = mailTo.split(";");
            List<String> toAddrs = new ArrayList<String>(mailToTokens.length);
            for (String mailToToken : mailToTokens)
            {
                String trimmedMailToToken = mailToToken.trim();
                if (!StringUtils.isEmpty(trimmedMailToToken)) {
                    if (doOutlookWorkaround) {
                        // The standard is no prefix SMTP
                        // Outlook Express supposidly works with or without prefix SMTP
                        // Outlook (like in Office) works only with prefix SMTP
                        // Thunderbird works always without prefix SMTP.
                        // Thunderbirds works sometimes with prefix SMTP: it even differs from Vista to Vista
                        trimmedMailToToken = "SMTP:" + trimmedMailToToken;
                    }
                    toAddrs.add(trimmedMailToToken);
                }
            }
            mail.setToAddrs(toAddrs);
        }

        Throwable errorException = info.getErrorException();
        Object[] messageParams;
        if (errorException != null) {
            messageParams = new Object[] {
                errorException,
                getStackTraceString(errorException)
            };
        } else {
            messageParams = new Object[] {
                info.getBasicErrorMessage(),
                info.getDetailedErrorMessage()
            };
        }

        String subject = getMessageByKeySuffix(".subject", messageParams);
        mail.setSubject(subject);

        String body = getMessageByKeySuffix(".body", messageParams);
        mail.setBody(body);

        try {
            Desktop.mail(mail);
        } catch (LinkageError e) {
            // Thrown by JDIC 0.9.3 on linux (and probably windows too) when native jars are not used properly
View Full Code Here

TOP

Related Classes of org.jdesktop.jdic.desktop.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.