Skip to main content

Posts

Showing posts from February, 2015

Populating Merge fields in Email Template through Apex

Hi All, I have explained same in my previous post. Due to some demerit of previous post, i have gone by this approach. Below is my previous post. http://salesforceworld4u.blogspot.in/2015/01/populating-merge-field-in-email.html http://salesforceworld4u.blogspot.co.uk/2013/12/sending-custom-object-information-in.html Now new approach would be override merge filed of email template through apex code and leaving static text as it is so that user will modify according to their needs. Below is code snippet License__c lc = [select id,name,Account_Name__c from License__c  where id = 'a0q90000001Tq7f' limit 1]; EmailTemplate empTemp = [Select Id,Body, subject,Name from EmailTemplate where Name ='Email Template to notify before 15 days' Limit 1];         String emailBody = empTemp.Body;         String emailSubject = empTemp.Subject;                 emailBody = emailBody.Replace('{!License__c...

Sending CSV attachment in Mail and Downloading in CSV Format

Hi All,  This post is all about sending CSV attachment and downloading in CSV format. Below is the page having list of accounts records in a table and button "Send", when clicked it will send a mail to user email id containing attachment of list Of accounts. Also download Results link to download contacts of corresponding account. Here the main page code - <apex:page controller="CSVAttachmentANDDownload">     <apex:form >         <apex:pageBlock >             <apex:pageBlockTable value="{!accountList}" var="account">                 <apex:column value="{!account.id}"/>                 <apex:column value="{!account.Name}"/>                 <apex:column value="{!account.Phone}"/>            ...