Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Email templates

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.






    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
    Member
    Join Date
    Feb 2012
    Posts
    58
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Email templates

    you can use a template engine such as Velocity or FreeMarker to template the email content.

Similar Threads

  1. JSP Email Attachments
    By DNisbet in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: November 9th, 2012, 02:16 PM
  2. Question(s) on Generics/Templates
    By Kumarrrr in forum Java Theory & Questions
    Replies: 4
    Last Post: January 7th, 2012, 09:44 AM
  3. email reader
    By rk.kavuri in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: March 4th, 2011, 03:59 AM
  4. JSP Email Attachments
    By DNisbet in forum Member Introductions
    Replies: 0
    Last Post: January 18th, 2011, 09:20 AM
  5. Images not going in email
    By anjali09s in forum Java SE APIs
    Replies: 3
    Last Post: August 2nd, 2009, 06:06 PM