Package com.centraview.email

Examples of com.centraview.email.MailMessage


    eventid = (String)dynaForm.get("eventid");
    String strAction = request.getParameter("action");     
   
    if(strAction !=null && !strAction.equalsIgnoreCase("cancel"))
    {
    MailMessage mailmessage  = new MailMessage();
    HashMap hm               = new HashMap();
      String mailTo = (String)dynaForm.get("composeTo");
      String mailFrom = (String)dynaForm.get("composeFrom");
      String subject = (String)dynaForm.get("composeSubject");
      String body = (String)dynaForm.get("composeMessage");
      String replyTo = (String)dynaForm.get("composeReplyTo");

      mailmessage.setMailFrom(mailFrom);
      mailmessage.setSubject(subject);
      mailmessage.setBody(body);
      mailmessage.setReplyTo(replyTo);
 
      String accountid               = (String) dynaForm.get("accountID");
      mailmessage.setAccountID(Integer.parseInt(accountid));
 
      FolderList fl                  = (FolderList) session.getAttribute("folderlist");
      Set listkey                    = fl.keySet();
      Iterator it                    = listkey.iterator();
 
      String smtpserver              = "";
      while (it.hasNext())
      {
      AccountDetail ad1  = (AccountDetail) fl.get(it.next());
      if (Integer.parseInt(accountid) == ad1.getAccountid())
      {
        smtpserver = ad1.getSmtpserver();
        mailmessage.setFolder(ad1.getFolderIDFromName("Sent", "SYSTEM"));
      } //end of if statement (Integer.parseInt(accountid) == ad1.getAccountid())
      } //end of while loop (it.hasNext())
      mailmessage.setSmtpserver(smtpserver);
 
      //message Date
      long l                         = (new java.util.Date()).getTime();
      mailmessage.setMessageDate( new java.sql.Timestamp( ) ) ;
 
      //Attchment
      HashMap attchmentids           = (HashMap) session.getAttribute("AttachfileList");
      mailmessage.setAttachFileIDs(attchmentids);
 
      session.removeAttribute("AttachfileList");
      EmailFacadeHome aa             = (EmailFacadeHome) CVUtility.getHomeObject("com.centraview.email.emailfacade.EmailFacadeHome", "EmailFacade");
      EmailFacade remote             = (EmailFacade) aa.create();
      remote.setDataSource(dataSource);
     
      //to
      StringTokenizer st             = new StringTokenizer(mailTo, ",");
      while (st.hasMoreTokens())
      {
        String addr = st.nextToken();
      ArrayList al = new ArrayList();
      if(addr!=null)
      {
        al.add(new MailAddress(addr));
        mailmessage.setTo(al);
        remote.sendMailMessage(individualID, mailmessage);
      }
      } //end of while loop (st.hasMoreTokens())
      }//end of if(strAction !=null..)
  } //end of try block
View Full Code Here


          newEventHashMap.put("StartDate", startTimestamp);
          newEventHashMap.put("EndDate", endTimestamp);

          //Add the attachment here
          MailMessage mailmessage = null;
          EmailFacadeHome cfh = (EmailFacadeHome)CVUtility.getHomeObject("com.centraview.email.emailfacade.EmailFacadeHome", "EmailFacade");
          EmailFacade facade = (EmailFacade)cfh.create();
          HashMap hm = new HashMap();
          hm.put("MessageID", new Integer(eventID));

          mailmessage = facade.getAttachment(individualId, hm);

          ArrayList attachments = mailmessage.getAttachmentID();
          HashMap newAttachments = new HashMap();
          if (attachments != null)
          {
            Iterator attachmentIterator = attachments.iterator();
            while (attachmentIterator.hasNext())
View Full Code Here

      // Why would we just pass the messageID to the method directly?!?
      HashMap hm = new HashMap();
      hm.put("MessageID", messageID);

      // get the message from the EJB layer
      MailMessage message = remote.getMailMessage(individualID, hm);

      // get all the To: addresses from the message
      // loop through, getting each address as a String,
      // add to a second ArrayList which gets set on the form bean
      ArrayList toList = (ArrayList)message.getTo();
      ArrayList formToList = new ArrayList();
      for (int i = 0; i < toList.size(); i++) {
        MailAddress ma = (MailAddress)toList.get(i);
        formToList.add((String)ma.getAddress());
      }
      emailForm.set("toList", formToList);
     
      // get all the Cc: addresses from the message
      // loop through, getting each address as a String,
      // add to a second ArrayList which gets set on the form bean
      ArrayList ccList = (ArrayList)message.getCc();
      ArrayList formCcList = new ArrayList();
      for (int j = 0; j < ccList.size(); j++) {
        MailAddress macc = (MailAddress)ccList.get(j);
        formCcList.add((String)macc.getAddress());
      }
      emailForm.set("ccList", formCcList);

      // set the From: field on the form bean
      emailForm.set("from", message.getMailFrom());
     
      // set the Date: field on the form bean
      Timestamp messageTimestamp = (Timestamp)message.getMessageDate();
      SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
      String date = dateFormatter.format(messageTimestamp);
      emailForm.set("date", date);
     
      // set the Subject: field on the form bean
      emailForm.set("subject", message.getSubject());
     
      // set the Body: field on the form bean
      emailForm.set("body", message.getBody());
     
    }catch(Exception e){
      System.out.println("[Exception][CV ViewEmailHandler] Exception thrown in execute(): " + e);
      allErrors.add("error.unknownError", new ActionMessage("error.unknownError"));
    }
View Full Code Here

  This method returns MailMessage object
  */

  public MailMessage getMailMessage( int userId, HashMap preference)
  {
    MailMessage mailmessage = new MailMessage();
    try
    {

    Integer messageid = (Integer)preference.get( "MessageID" );
    int id = messageid.intValue();

    //System.out.println( "*****Message ID***** " + id );

    CVDal cvdl = new CVDal(dataSource);
    Collection v = null;



    cvdl.setSql("email.getcreatetable");
       cvdl.executeUpdate();
       cvdl.clearParameters();

       cvdl.setSql("email.getmailinsert");
       cvdl.setInt( 1, id );
    cvdl.executeUpdate();
       cvdl.clearParameters();

       cvdl.setSql("email.getmailupdate1");
       cvdl.executeUpdate();
       cvdl.clearParameters();

    cvdl.setSql("email.getmailselect");
    v = cvdl.executeQuery();
     cvdl.clearParameters();

    cvdl.setSql("email.getmaildrop");
       cvdl.executeUpdate();
       cvdl.clearParameters();
    cvdl.destroy();


    //System.out.println( " ***** Main Query Complete ***** " );

       Iterator it = v.iterator();
    HashMap hm = ( HashMap  )it.next();


    MailAccount mailaccount = new MailAccount();

    int AccountID =  ((Long)hm.get( "AccountID" )).intValue() ;

    //System.out.println( "MailAccount" + AccountID );


    /**
    mailmessage.setAccountID( AccountID  );
    if ( ( ((Long)hm.get( "AttachmentID" )).intValue() ) != 0)
    {
      mailmessage.setAttachmentID(  ((Long)hm.get( "AttachmentID" )).intValue() ) ;
    }
    */

    if ( (String)hm.get( "Body" ) != null )
    {
      //System.out.println( "Body" + (String)hm.get( "Body" ) );
      mailmessage.setBody( (String)hm.get( "Body" ) ) ;
    }
    //  mailmessage.setFolder( ((Long)hm.get( "folder" )).intValue() ) ;

    if ( hm.get( "FromIndividual" ) != null )
    {
      mailmessage.setFromIndividual( ((Long)hm.get( "FromIndividual" )).intValue() );
    }

    if ( (String)hm.get( "Headers" ) != null )
    {
      // IQ Added for headers
      //System.out.println( "Headers" + (String)hm.get( "Headers" ) );
      String allHeader = (String)hm.get( "Headers" );
      mailmessage.setHeaders( allHeader );
/*
      if (allHeader != null && allHeader.length() > 0)
      {
        StringTokenizer st = new StringTokenizer(allHeader,Constants.EH_HEADER_DELIMETER);

        while (st.hasMoreTokens()) {
            String fullHeader = st.nextToken();
          int eqIndx = fullHeader.indexOf(Constants.EH_KEYVALUE_DELEMETER);
          mailmessage.setHeadersHM(fullHeader.substring(0,eqIndx).trim(),fullHeader.substring(eqIndx+1).trim());
        }
      }
*/
    }

    if ( (String)hm.get( "Importance" ) != null )
    {
      //System.out.println( "Importance" + (String)hm.get( "Importance" ) );
      mailmessage.setImportance( (String)hm.get( "Importance" ) ) ;
    }

    if ( ( Timestamp )hm.get( "MessageDate" ) != null )
    {
      //System.out.println( "MessageDate" + ( Timestamp )hm.get( "MessageDate" ) );
      mailmessage.setMessageDate( ( Timestamp )hm.get( "MessageDate" ) );
    }

    if ( ( ((Long)hm.get( "MessageID" )).intValue() ) != 0)
    {
      //System.out.println( "MessageID" + ( ((Long)hm.get( "MessageID" )).intValue() ) );
      mailmessage.setMessageID( ((Long)hm.get( "MessageID" )).intValue() ) ;
    }

    if ( ( String )hm.get( "Priority" ) != null )
    {
      //System.out.println( "Priority" + ( String )hm.get( "Priority" ) );
      mailmessage.setPriority( (String)hm.get( "Priority" ) ) ;
    }
    //  mailmessage.setStatus( (String)hm.get( "Status" ) ) ;
    if ( ( String )hm.get( "Subject" ) != null )
    {
      //System.out.println( "Subject" + ( String )hm.get( "Subject" ) );
      mailmessage.setSubject( (String)hm.get( "Subject" )) ;
    }


    mailmessage.setTheMailAccount( mailaccount ) ;

    if ( ( String )hm.get( "MailFrom" ) != null )
    {
      //System.out.println( "MailFrom" + ( String )hm.get( "MailFrom" ) );
      mailmessage.setMailFrom( (String)hm.get("MailFrom")) ;
    }


    ArrayList to = new ArrayList();
    ArrayList cc = new ArrayList();
    ArrayList bcc = new ArrayList();
    // to

    CVDal cvdlto = new CVDal(dataSource);
    Collection vto = null;
    cvdlto.setSql("email.getmailaddressTO");
    cvdlto.setInt( 1 , id );

    vto = cvdlto.executeQuery();
     cvdlto.clearParameters();
    cvdlto.destroy();
    Iterator itto = vto.iterator();

       while( itto.hasNext() )
       {
      HashMap hmto = ( HashMap  )itto.next();
      String addto = (String) hmto.get( "Address" );
      //System.out.println( addto );
      to.add ( new MailAddress( addto ) );
       }



    // CC

    CVDal cvdlcc = new CVDal(dataSource);
    Collection vcc = null;
    cvdlcc.setSql("email.getmailaddressCC");
    cvdlcc.setInt( 1 , id );
    vcc = cvdlcc.executeQuery();
     cvdlcc.clearParameters();
    cvdlcc.destroy();
    Iterator itcc = vcc.iterator();
    int i=0 ;
       while( itcc.hasNext() )
       {
         i++;
      HashMap hmcc = ( HashMap  )itcc.next();
      String addcc = (String) hmcc.get( "Address" );
      //System.out.println( addcc );

      cc.add ( new MailAddress( addcc ) );
       }


    //BCC
    // change from shirish ,linesh
    CVDal cvdlbcc = new CVDal(dataSource);
    Collection vbcc = null;
    cvdlbcc.setSql("email.getmailaddressBCC");
    cvdlbcc.setInt( 1 , id );

    vbcc = cvdlbcc.executeQuery();
     cvdlbcc.clearParameters();
    cvdlbcc.destroy();
    Iterator itbcc = vbcc.iterator();

       while( itbcc.hasNext() )
       {
      HashMap hmbcc = ( HashMap  )itbcc.next();
      String addbcc = (String) hmbcc.get( "Address" );
      //System.out.println("bcc"+ addbcc );
      bcc.add ( new MailAddress( addbcc ) );
       }

    //End  change from shirish ,linesh
    mailmessage.setTo( to ) ;
    mailmessage.setCc( cc) ;
    mailmessage.setBcc( bcc) ;

    //  mailmessage.setBcc( (String)hm.get( "bcc" ) ) ;



    /** Attachment added on 29-07-2003 */
    CVDal cvdlattch = new CVDal(dataSource);
    Collection attch = null;
    cvdlattch.setSql("email.getallattachments");
    cvdlattch.setInt( 1, id );
       attch = cvdlattch.executeQuery();
       cvdlattch.clearParameters();
    cvdlattch.destroy();


    Iterator itattch = attch.iterator();
    ArrayList arrayattch = new ArrayList();

    while( itattch.hasNext() )
       {
         HashMap hmattach = ( HashMap  )itattch.next();
      int AttachmentID = ( (Long) hmattach.get( "AttachmentID" )).intValue() ;
      int MessageID = ((Long) hmattach.get( "MessageID" )).intValue();
      int FileID = ((Long) hmattach.get( "FileID" )).intValue();
      String FileName = (String) hmattach.get( "FileName" );
      //System.out.println(AttachmentID + " "+MessageID + " "+FileID+ " "+FileName );
      Attachment a = new Attachment( AttachmentID, MessageID, FileID, FileName  );
      arrayattch.add( a );
       }

    mailmessage.setAttachmentID( arrayattch );


    /** attchment End  */


 
View Full Code Here

    return true;
  }

  public MailMessage getAttachment( int userId, HashMap preference)
  {
    MailMessage mailmessage = new MailMessage();
    CVDal cvdl = new CVDal(dataSource);
    try
    {

      Integer messageid = (Integer)preference.get( "MessageID" );
      int id = messageid.intValue();

//      System.out.println( "*****Message ID***** " + id );
      Collection v = null;

      Collection attch = null;
      cvdl.setSql("email.getallattachments");
      cvdl.setInt( 1, id );
       attch = cvdl.executeQuery();

      Iterator itattch = attch.iterator();
      ArrayList arrayattch = new ArrayList();

      while( itattch.hasNext() )
       {
         HashMap hmattach = ( HashMap  )itattch.next();
        int AttachmentID = ( (Long) hmattach.get( "AttachmentID" )).intValue() ;
        int MessageID = ((Long) hmattach.get( "MessageID" )).intValue();
        int FileID = ((Long) hmattach.get( "FileID" )).intValue();
        String FileName = (String) hmattach.get( "FileName" );
//        System.out.println(AttachmentID + " "+MessageID + " "+FileID+ " "+FileName );
        Attachment a = new Attachment( AttachmentID, MessageID, FileID, FileName  );
        arrayattch.add( a );
       }

      mailmessage.setAttachmentID( arrayattch );
    }
    catch( Exception e )
    {
      System.out.println("[Exception][GetMailEJB.getAttachment] Exception Thrown: "+e);
      e.printStackTrace();
View Full Code Here

  public MailMessage getMailMessage( int userId, HashMap preference) throws AuthorizationFailedException
  {
    if(!CVUtility.isModuleVisible("Email",userId, this.dataSource))
      throw new AuthorizationFailedException("Email- getMailMessage");
    MailMessage  mailmessage = null;
       try
      {
        InitialContext ic = CVUtility.getInitialContext();
        GetMailLocalHome home = (GetMailLocalHome)ic.lookup("local/GetMail");
        GetMailLocal remote =  home.create();
View Full Code Here

  public MailMessage getAttachment( int userId, HashMap preference) throws AuthorizationFailedException
  {
    if(!CVUtility.isModuleVisible("Email",userId, this.dataSource))
      throw new AuthorizationFailedException("Email- getAttachment");
    MailMessage  mailmessage = null;
       try
      {
        InitialContext ic = CVUtility.getInitialContext();
        GetMailLocalHome home = (GetMailLocalHome)ic.lookup("local/GetMail");
        GetMailLocal remote =  home.create();
View Full Code Here

TOP

Related Classes of com.centraview.email.MailMessage

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.