• Prashant Naik 12
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I'm finding difficult to pass the template letterhead, where we have an company logo, in apex and mail coming it as blank, not showing any letters and logo.

So request you to kindly verify below code and let me know what is missing please.
// Get your header template
List<BrandTemplate> emailHeaderTemplates = [SELECT Id, Value FROM BrandTemplate WHERE Id = :brandTemplateId LIMIT 1];
String emailHeader = emailHeaderTemplates[0].Value;
System.debug('#### Email Header' +emailHeader);

// Get the Template Logo from the Document tab
List<Document> LogoDoc = [Select Id,Name from Document where Name = 'Test Logo'];
string strOrgId = UserInfo.getOrganizationId();
string orgInst = URL.getSalesforceBaseUrl().getHost();
orgInst = orgInst.substring(0, orgInst.indexOf('.')) +  '.my.salesforce.com';
string strDocUrl = URL.getSalesforceBaseUrl().getProtocol() + ':' + orgInst + '/servlet/servlet.ImageServer?id=' + LogoDoc[0].Id + '&oid=' + strOrgId;
System.debug('### Test Logo' + strDocUrl);

// Prepare to pass header + body into the renderEmailTemplate method as a list of strings, in the order they should appear in the finished email

System.debug('### EmailTemplate' +emailTemplate);
String emailBody = emailTemplate.Body;
String htmlBody = emailTemplate.HtmlValue;
Map<String,String> data = new Map<String,String>();

System.debug('### html' +htmlBody);

List<String> contentParts = new List<String>{emailHeader, htmlBody};
String subject = emailTemplate.Subject;
subject = subject.replace('{!Case.CaseNumber}',cn);
system.debug('### email subj '+subject);

List<Messaging.RenderEmailTemplateBodyResult> resList = Messaging.renderEmailTemplate('', Creation.id, contentParts);
String compiledBody = '';
String img ='';
for(Integer i=0, len=resList.size(); i < len; i++){
compiledBody += resList[i].getMergedBody();
}
system.debug('### compiledb '+compiledBody);

List<String> sendTo = new List<String>();
sendTo.add(Creation.Caller_Email__c);
if(owea!= null) {
mail.setOrgWideEmailAddressId(owea.id);
}
mail.setToAddresses(sendTo);
mail.setTargetObjectId(UserInfo.getUserId());
mail.setUseSignature(true);
mail.setSubject(subject);
mail.setSaveAsActivity(false);
mail.setTemplateId(emailTemplate.id );
if(htmlBody!=null){
mail.setHtmlBody(compiledBody + strDocUrl);

}else{
mail.setPlainTextBody(compiledBody + strDocUrl);
}
mail.setTreatBodiesAsTemplate(true);
mails.add(mail);
system.debug(Mail);
I want to create the Child case when parent is closed and this child case should create manaully and also from Email-to-Case..
Hi, I have problem in the challenge which is as follows : 
Create a Lightning Component to display a single item for your packing list.
  • Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
  • Add an attribute named item for type Camping_Item__c that is required.
for this I made component campingListItem.cmp which has following code :
<aura:component>
    <aura:attribute name="item" type="Camping_Item__c" />    
    <p>Name:<ui:outputText value="{!v.item.Name}"/></p>    
    <p>Quantity:<ui:outputNumber value="{!v.item.Quantity__c}"/></p>    
    <p>Price:<ui:outputCurrency value="{!v.item.Price__c}"/></p>
    <p>Packed?:<ui:outputCheckbox value="{!v.item.Packed__c}"/></p>
</aura:component>

but data is not displaying from object simple HTML text is displaying as follows:
Name:
Quantity:
Price:
Packed?:  False

please give me some suggestion.