2017-05-30 67 views
0
As per the requirement I am sending a pdf file attachment to some email ids,I thought to include some static text to show in the email and i created one text template and added in the code ,but the text is not showing in the email. 

來這裏是我以前setTemplateId顯示模板代碼 ...文本電子郵件模板未在郵件

Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); 
      attach.setContentType('application/pdf');   
      attach.setFileName(************************); 
      attach.setInline(false); 
      attach.Body = body; 

      Messaging.SingleEmailMessage mail = new 
      Messaging.SingleEmailMessage(); 
      EmailTemplate et=[Select id from EmailTemplate where 
      name=:'CSPdfEmailtemplate']; 
      mail.setUseSignature(false); 
      mail.setToAddresses(Emailids); 
      mail.setTemplateId(et.id);//here i am giving the id of template 
      mail.setBccSender(true); 

回答

0

documentation使用模板singleEmailMessage需要有ID與setTargetObjectId(targetObjectId)的聯繫人,用戶或潛在客戶,因此您需要添加該聯繫人。