Package org.openbravo.erpCommon.businessUtility

Examples of org.openbravo.erpCommon.businessUtility.EMail


          log4j.debug(smtpHost + "\n" + from + "\n" + to + "\n" + data[0].mailsubject + "\n"
              + data[0].mailtext);
        if (log4j.isDebugEnabled())
          log4j
              .debug("*************************************************************************************************");
        EMail email = new EMail(vars, smtpHost, from, to, data[0].mailsubject, data[0].mailtext);
        msg = email.send();
        if ("OK".equals(msg)) {
          RequestActionData.update(conn, this, Utility.messageBD(this, "RequestActionEMailOK", vars
              .getLanguage()), strKey);
        } else {
          RequestActionData.update(conn, this, Utility.messageBD(this, "RequestActionEMailError",
              vars.getLanguage())
              + " - " + msg, strKey);
        }
      } else if (data[0].actiontype.equals("T")) {
        String subject = Utility.messageBD(this, "RequestActionTransfer", vars.getLanguage());

        RequestActionData.update(conn, this, subject, strKey);
        String smtpHost = EmailData.selectSMTPHost(conn, this, data[0].adClientId);
        String to = "";
        EmailData[] dataTo = EmailData.selectEmail(conn, this, data[0].adUserId);
        if (dataTo != null && dataTo.length > 0) {
          to = dataTo[0].email;
        }
        to = to.trim().toLowerCase();
        for (int pos = to.indexOf(" "); pos != -1; pos = to.indexOf(" "))
          to = to.substring(0, pos) + to.substring(pos + 1);

        if (to.equals("")) {
          to = System.getProperty("user.name") + "@"
              + Utility.getContext(this, vars, "#AD_Client_Name", windowId) + ".com";
          to = to.trim().toLowerCase();
          for (int pos = to.indexOf(" "); pos != -1; pos = to.indexOf(" "))
            to = to.substring(0, pos) + to.substring(pos + 1);
        }
        String from = "";
        EmailData[] mails = EmailData.selectEmail(conn, this, data[0].updatedby);
        if (mails == null || mails.length == 0) {
          mails = EmailData.selectEmailRequest(conn, this, data[0].adClientId);
          if (mails != null && mails.length > 0) {
            from = mails[0].email;
            from = from.trim().toLowerCase();
            for (int pos = from.indexOf(" "); pos != -1; pos = from.indexOf(" "))
              from = from.substring(0, pos) + from.substring(pos + 1);
            vars.setSessionValue("#Request_EMail", from);
            vars.setSessionValue("#Request_EMailUser", mails[0].emailuser);
            vars.setSessionValue("#Request_EMailUserPw", mails[0].emailuserpw);
          }
        } else {
          from = mails[0].email;
          from = from.trim().toLowerCase();
          for (int pos = from.indexOf(" "); pos != -1; pos = from.indexOf(" "))
            from = from.substring(0, pos) + from.substring(pos + 1);
          vars.setSessionValue("#User_EMail", from);
          vars.setSessionValue("#User_EMailUser", mails[0].emailuser);
          vars.setSessionValue("#User_EMailUserPw", mails[0].emailuserpw);
        }

        if (from.equals("")) {
          from = System.getProperty("user.name") + "@"
              + Utility.getContext(this, vars, "#AD_Client_Name", windowId) + ".com";
          from = from.trim().toLowerCase();
          for (int pos = from.indexOf(" "); pos != -1; pos = from.indexOf(" "))
            from = from.substring(0, pos) + from.substring(pos + 1);
        }
        String message = subject + "\n" + data[0].summary;
        if (log4j.isDebugEnabled())
          log4j
              .debug("*************************************************************************************************");
        if (log4j.isDebugEnabled())
          log4j.debug(smtpHost + "\n" + from + "\n" + to + "\n" + subject + "\n" + message);
        if (log4j.isDebugEnabled())
          log4j
              .debug("*************************************************************************************************");
        EMail email = new EMail(vars, smtpHost, from, to, subject, message);
        email.send();
      }

      releaseCommitConnection(conn);
    } catch (Exception e) {
      try {
View Full Code Here


            .prepareMails(connection, alertRule.adAlertruleId);

        if (mail != null) {
          for (int i = 0; i < mail.length; i++) {
            String head = Utility.messageBD(connection, "AlertMailHead", mail[i].adLanguage) + "\n";
            EMail email = new EMail(null, mail[i].smtphost, mail[i].mailfrom, mail[i].mailto,
                "[OB Alert] " + alertRule.name, head + msg);
            String pwd = FormatUtilities.encryptDecrypt(mail[i].requestuserpw, false);
            email.setEMailUser(mail[i].requestuser, pwd);
            if ("OK".equals(email.send())) {
              logger.log("Mail sent ok.");
            } else {
              logger.log("Error sending mail.");
            }
          }
View Full Code Here

  private boolean sendIndividualMail(Connection conn, VariablesSecureApp vars, String smtpHost,
      String from, String subject, String message, String name, String EMailAddress,
      String AD_User_ID, String fromID, String fromPW, StringBuffer g_log) throws IOException,
      ServletException {
    EMail email = new EMail(vars, smtpHost, from, EMailAddress, subject, message);
    if (!email.isValid()) {
      log4j.warn("sendIndividualMail NOT VALID - " + EMailAddress);
      try {
        SendMailTextData.update(conn, this, AD_User_ID);
        g_log.append(Utility.messageBD(this, "AD_User_ID", vars.getLanguage()) + ": " + AD_User_ID
            + " " + Utility.messageBD(this, "Deactivated", vars.getLanguage()) + "<br>");
      } catch (ServletException e) {
        e.printStackTrace();
        log4j.warn("Rollback in transaction");
      }
      return false;
    }
    email.setEMailUser(fromID, fromPW);
    boolean OK = "OK".equals(email.send());
    if (OK) {
      if (log4j.isDebugEnabled())
        log4j.debug("sendIndividualMail OK - " + EMailAddress);
    } else
      log4j.warn("sendIndividualMail FAILURE - " + EMailAddress);
View Full Code Here

TOP

Related Classes of org.openbravo.erpCommon.businessUtility.EMail

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.