Results 1 to 2 of 2

Thread: Email templates

  1. #1
    charanyevadu is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Default Email templates

    Hello folks,

    Iam oracle developer and very much new to java and assigned task on java related.

    Below is my java code to send emails to customers where there is some hard coded text in between and the data from the database fields.When ever user want to change the content of the mail, they has to request the developer to do so, which is a hectic task. So its better to give the rights to change the content when required and this changes should reflect next time onwards. How this can be solved whether need to create any tables or is there any other way to do so in Java.



    Java Code:
    public class AccountingApprove extends SuperSOA6
    {
        public AccountingApprove(BMAConnection scon, BMAAbstractLogDispatcher logMgr, 
            Vector vRow, CCObject ccMaker, char who, ClaimDateObject claimObj)   throws Exception
        {
            super(scon, logMgr, vRow, ccMaker, claimObj);
            this.who = who;
            subject = " CLAIM APPROVED";
            comment = "CLA APP";
     //       try
     //       {
                //Get sender list from MainObject. If sender list not found, use default sender - defined in property file
                //Sender is the first person in signature loop
                /*String senderGlobalId = (String)vRow.elementAt(MainObject.LAST_UPD_BY);
                String senderList = "";
                if(senderGlobalId != null){
                    senderList = MainObject.senderList.getEmailId(senderGlobalId);
                }
                if(senderList.length() > 0){
                    super.sender = senderList;
                }*/
     
                String adjNo = (String)vData.elementAt(ADJ_NO);
     
                String senderEmail = MainObject.senderList.getClaimSender(adjNo);
                if(senderEmail.length() > 0){   //overwrite default sender
                    super.sender = senderEmail;
                }
     
     
                populateSendVec();
                generateReport();
    //        }
    //        catch(Exception err)
    //        {
    //            logMgr.log(new BMALogEvent("test",BMALogLevelConstants.BASIC, err));
    //        }
        }
     
        private void generateReport() throws Exception
        {
    /*    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
            C         SUBROUTINE FOR PRINTING ACCOUNTING APPROVED C
            CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/
            BMADateWrapper subDat = (BMADateWrapper)vData.elementAt(SUB_DATE);
            String palm = (String)vData.elementAt(PALM);
            String prgm = (String)vData.elementAt(PRGM);
            String resend = (String)vData.elementAt(RESEND);
            String cust = (String)vData.elementAt(CNAME);
            String ssvno = (String)vData.elementAt(SSVNO);
            Vector vCust = getGivenCustomer();
            String prod = (String)vData.elementAt(PRD);
            String year = (String)vData.elementAt(YR);
            String country = (String)vData.elementAt(COUNTRY);
            String qtr = (String)vData.elementAt(QTR);
            String custNo = (String)vData.elementAt(BILL_NO);
            String custRef = (String)vData.elementAt(REF);
            String desc = (String)vData.elementAt(DESC);
            String email = (String)vCust.elementAt(CCObject.E_EMAIL);
            BMADateWrapper startDate = (BMADateWrapper)vData.elementAt(START_DATE);
            BMADateWrapper endDate = (BMADateWrapper)vData.elementAt(END_DATE);
            String adjNo = (String)vData.elementAt(ADJ_NO);
            String approve = (df.format((Double)vData.elementAt(APPROVE))).toString();
            String claim = (df.format((Double)vData.elementAt(CLAIM))).toString();
            String credit = (df.format((Double)vData.elementAt(CREDIT))).toString();
            String creditNo =(String)vData.elementAt(CREDIT_NO);
            BMADateWrapper creditDate = (BMADateWrapper)vData.elementAt(CREDIT_DATE);
     
            Vector vAuditor = ccMaker.findType(CCObject.AUDITOR);
            // ADDED NOV 2001
            if ((vAuditor == null)||(vAuditor.isEmpty()))
            {
                vAuditor = ccMaker.getAuditor(vData, true);
                vInternal.addElement(vAuditor);
            }
            String aEmpl = (String)vAuditor.elementAt(CCObject.I_EMPL);
            String aName = (String)vAuditor.elementAt(CCObject.I_NAME);
            String aEmail = (String)vAuditor.elementAt(CCObject.I_EMAIL_A);
            String aEmailId = (String)vAuditor.elementAt(CCObject.I_EMAIL);
            String aFax = (String)vAuditor.elementAt(CCObject.I_FAX);
            String aPhone = (String)vAuditor.elementAt(CCObject.I_PHONE);
            rpt(" ");
     
            StringBuffer line = new StringBuffer();
            line.append(spacesX(28));
            line.append("* CLAIM PAID IN FULL NOTICE *");
            doHeader(line.toString());
     
            line = new StringBuffer();
            line.append(" Customer Reference No.: ");
            line.append(spacesA(30, custRef));
            rpt(line.toString());           
     
            line = new StringBuffer();
            line.append("   Activity Description: ");
            //line.append(spacesA(57, desc));
            line.append(spacesA(60, desc)); //changed on Mar 16,2004
            rpt(line.toString());      
     
            Vector vCom = com.getAllComments("C");
            linePrinted = false;
            for(int i=0; i<vCom.size(); i++)
            {
                String data = (String)((Vector)vCom.elementAt(i)).elementAt(Comments.DATA);
                line = new StringBuffer();
                if(linePrinted)
                {
                    line.append(spacesX(25));
                    line.append(spacesA(60, data));
                }
                else
                {
                    line.append("      Activity Comments: ");
                    line.append(spacesA(60, data));
                    linePrinted = true;
                }
                rpt(line.toString());
            }
            /*rpt(" ");        
     
            line = new StringBuffer();
            line.append(" Customer Claimed Amount: $");
            line.append(spacesF(10, claim));
            rpt(line.toString());      
     
            line = new StringBuffer();
            line.append("     bmcc Paid Amount: $");
            line.append(spacesF(10, credit));
            line.append("     bmcc Credit Memo #: ");
            line.append(spacesA(16, creditNo));
            rpt(line.toString());      
     
            line = new StringBuffer();
            line.append(spacesX(38));
            line.append("         Credit Memo Date: ");
            line.append(spacesA(11, creditDate.toString()));
            rpt(line.toString()); */
     
            Vector vCrNums = parseMemoNumber(creditNo);
     
            line = new StringBuffer();
            line.append("   Total Approved Amount: $");
            line.append(spacesF(10, approve));
            line.append("    Payment Date: ");
            line.append(spacesA(11, creditDate.toString()));
            rpt(line.toString());
     
            line = new StringBuffer();
            line.append(" Customer Claimed Amount: $");
            line.append(spacesF(10, claim));
            line.append("     Payment No.: ");
            if ((vCrNums != null)&&(vCrNums.size() > 0))
            {
                line.append(vCrNums.elementAt(0));
            }
            rpt(line.toString());      
     
            line = new StringBuffer();
            line.append("     bmcc Paid Amount: $");
            line.append(spacesF(10, credit));
            line.append(spacesX(28));
            if ((vCrNums != null)&&(vCrNums.size() > 1))
            {
                line.append(vCrNums.elementAt(1));
            }
            rpt(line.toString());      
     
            line = new StringBuffer();
            line.append(spacesX(37));
            line.append(spacesX(28));
            if ((vCrNums != null)&&(vCrNums.size() > 2))
            {
                line.append(vCrNums.elementAt(2));
            }
            rpt(line.toString());
     
            line = new StringBuffer();
            line.append(" Dear ");
            line.append(spacesA(15, findFirst((String)vCust.elementAt(CCObject.E_NAME))));
            rpt(line.toString());      
     
            rpt(" ");
            rpt(" The audit of your claim, referenced above, has resulted in payment in full.     ");       
            rpt(" Please contact me if you have questions regarding the content of this notice.   ");      
     
            rpt(" ");
            doFooter("Sales Prog. Auditor", vAuditor);
     
            rpt(" ");
            printCC();
        }
    	//{{DECLARE_CONTROLS
    	//}}
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: Email templates

    You can use a template engine, something like Velocity Apache Velocity Site - The Apache Velocity Project or FreeMarker FreeMarker: Java Template Engine Library - Overview will help you to create an email template. And then you can supply this template with some information from your Java code.

Similar Threads

  1. HELP! - Eclipse Templates
    By protocos in forum Eclipse
    Replies: 1
    Last Post: 03-06-2009, 03:31 AM
  2. send email using apache commons email
    By jnamendi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-14-2008, 06:55 PM
  3. Templates JSP
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2007, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •