function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AKallAKall 

Body of Visualforce email Template is missing.

I have encountered a strange problem with a visualforce email template. When I preview the template everything seems to be fine. It appears as I expect in the preview window of the salesforce interface, and the test emails that I send to myself via the 'Preview' button arrive without a problem. However, when the approval process rule triggers the email to be sent the only thing that my users are receiving is an email with the subject only...the body of the email is completely blank! I have yet to figure out why this is, so if anybody has any suggestions I would be very grateful.
Code:
<messaging:emailTemplate subject="New Web-to-Trial Request requires your Approval" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody >
   <html>
     <body>
    
    <style type="text/css">
      p.regular {font-family: arial; size: 8pt;}
      p.small {font-family: arial; size 8pt; line-height: 100%}
    </style>  
    <p class="regular">
    <br>A New Trial Request has been submitted.</br>
    <br>Account: <apex:outputLabel >{!relatedTo.Account.Name}</apex:outputLabel></br>
    <br><apex:outputText >Requested By: {!relatedTo.Contact__r.Name}</apex:outputText></br> 
     <br>To approve, simply type 'Approved' in your response. You can also review the Opportunity or Approve online at https://emea.salesforce.com/{!relatedTo.Id}</br>
     </p>
     </body>
   </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 


Message Edited by AKall on 01-16-2009 01:26 PM
Best Answer chosen by Admin (Salesforce Developers) 
AKallAKall
It looks like the release of Summer 09 has solved my problem!

All Answers

AKallAKall
Upon investigating further, it seems that this is not a visualforce problem, but an approval process configuration problem. I have discovered that any email template that I use arrives blank, including email templates that work just fine in other workflows & approvals actions. There seems to be something particular about the configuration of the 'Approval Assignment Email Template'. I have also learned that there is a default template that Salesforce provides, if the field is left blank. This default template is working fine, so the problem is no longer an emergency. Nevertheless, it is a strange problem and it would be nice to be able to use my own email one day.
Alex 2.0Alex 2.0

I'm having the same problem too.

 

If I send a test messsage, all looks good. When I try sending through apex, with an attachment, I get the subject line and the attachment just fine, but the body of the email is empty!

 

Any idea why this is happening? I don't think we have any approvals setup...

 

Thanks,

 

--Alex

 

GuyClairboisGuyClairbois

Hi,

Did any of you guys find out why this is happening?

 

We are experiencing the same problem. It used to work fine on our Live environment, but after I did some modifications to the VisualForce code in the e-mail template, the e-mail started to be blank.The exact same template works fine on our Sandbox environment.

 

I suspect that there is an error when building the VisualForce page, but there is no way of viewing that error since it happens as part of a background workflow process.

Since the preview work fine (also for us) I also suspect that this has to do with authorizations of some kind. The user profiles, however, are exactly equal on both our Live and Sandbox environments.

 

It would be great if anybody can help us in the right direction..

dchasmandchasman
I pinged the Messaging team this morning and asked them to reach out to you about this. Stay tuned.
AKallAKall
Soon after I made my original post back in Jan. I spoke with someone in salesforce tech Support. If I remember correctly they told me that VF email templates were not yet supported by workflow rules and approval steps. Therefore, I gave up on using them and began using the standard txt format. Can anybody confirm that VF templates are still not supported by workflow rules and approval steps?
ccopekccopek

AKall, We did have some problems earlier in the year with VF Templates when sent in an Email Action triggered from a Time-based workflow, but that issue was corrected. Perhaps the tech support rep was referring to that issue. I tried setting up a basic scenario using the VF template referenced in your first post, using it as an "Approval Assignment Email Template". The email was rendered fine when I submitted an approval. You should be able to use VF templates in workflow rules and approval steps.

 

I'm unable to reproduce any of the problems being described in this thread. If you could provide the following information, it might be helpful for me to track down the problem you are having:

 

1. Describe the steps you perform in the application that triggers the sending of an email. For Example: Create a new Contact with name equal to 'ABC' which triggers a Workflow Email Action that sends a VF Template.

2. If you can provide me your orgId, I can view your metadata, and try to setup a similar scenario on my test org using the steps you provide in #1.

3. Provide the Email Template name/Id that is causing you the problem

 

With this information, I can try reproducing the problem you are having and come back with a proposal on how to get it resolved.

 

Chris

GuyClairboisGuyClairbois

Hi Chris,

do you mind if I provide my problem description of the same problem?

 

1. The steps we perform in the application are:

- update a picklist in a Custom Object to a certain value. 

- this triggers a workflow email action that sends out a VisualForce email template

2. Org Id for our Configuration Sandbox, where this also happens, is 00DS0000000ExEj

3. Any VF email template has this problem

 

Important: if step 1 is performed manually on the object, the email is fine. If step 1 is performed by APEX code, then the email body is empty.

Also when viewing the VF example, it is fine, also the test email is fine.

 

I'd be happy to provide more info, since this is really an urgent problem for my organization.

Thanks in advance,

Guy

ccopekccopek

Guy,

 

Thanks for providing additional information.  The request for more information was for everyone who was having problems, not just AKall.  I didn't word my post very well.  

 

I will take a look at your org and see if I can determine what the problem is and get back to you.  With the weekend coming up, I will try to get you a response by Monday.

 

Chris

DiceManDiceMan

Chris,

 

I'm having the exact same problem in our org. A VF email template that has been tested on our sandbox is appearing blank when sent from the live system. 

 

1. The workflow action sending the email is triggered when a case status moves the "AOM Acknowledged", the case Type is "Return", the case record type is "FR" and the account number 1288888 (out test account).

2. Org Id of our live environment is 00D200000001Dld, where we do observe the problem. Out sandbox is 00DR00000005XOO, where we did not have this problem.

3.  Code attached.

 

On Monday I'll try to reduce the code to try and isolate the minimum template that has the problem.

 

Regards

 

David

 

 

<messaging:emailTemplate subject="Balise: {!relatedTo.CaseNumber}" recipientType="Contact" relatedToType="Case"> <messaging:htmlEmailBody > <html> <head> <style type="text/css"> body, html { font-family: "Arial" "Sans-Serif"; font-weight: normal; font-size: 10pt; color: Black; } table { width: 90%; margin-left: 3.5pt; border-collapse: collapse; font-size: 11.5pt; } table.balise { font-size: 14pt; } p { margin-left: 3.5pt; } </style> </head> <body> <p>Cher client Chère cliente</p> <p>Veuillez trouvez ci-dessous votre balise de retour à compléter et à coller impérativement sur votre colis.</p> <p>La liste des produits ci-dessous récapitule vos déclarations enregistrées sous le numéro de dossier : {!relatedTo.AOM_Returns_Price_Adjustment_Order_No__c}</p> <p>Sincères salutations,</p> <p>{!relatedTo.Owner.Name}</p> <p>Le service client Spicers France</p> <table border="0" cellpadding="10" cellspacing="0"> <thead> <tr> <th>Code</th> <th>Description</th> <th>Commande originale</th> <th>Quantité</th> <th>Prix</th> <th>Date création</th> </tr> </thead> <tbody> <apex:repeat value="{!relatedTo.CaseProducts__r}" var="prod"> <tr> <td><apex:outputText value="{!prod.Product_Code__c}" /></td> <td><apex:outputText value="{!prod.Product_Description__c}" /></td> <td><apex:outputText value="{!prod.Original_order_Number__c}" /></td> <td><apex:outputText value="{!prod.Quantity__c}" /></td> <td><apex:outputText value="{!prod.Price__c}" /></td> <td><apex:outputField value="{!prod.CreatedDate}" /></td> </tr> </apex:repeat> </tbody> </table> <br/> <table class="balise" border="1" cellspacing="0" cellpadding="0"> <tr style="height: 37.1pt; text-align: center;"> <td colspan="2"> <p> <b>BALISE DE REPRISE A COLLER IMPERATIVEMENT SUR LE SUR-EMBALLAGE DE VOTRE COLIS</b></p> </td> </tr> <tr style="height: 36.5pt;"> <td rowspan="2" style="width: 672px;"> <p> <b>No de Compte et Nom du Client:</b> {!relatedTo.Account_Number__c} {!relatedTo.Account__r.Name}</p> <p> <b>Nom et Adresse de l'enlèvement :</b> {!relatedTo.Name1__c} {!relatedTo.Name2__c}<br /> {!relatedTo.Street1__c}<br /> {!relatedTo.Street2__c}<br /> {!relatedTo.Street3__c}<br /> {!relatedTo.City__c}<br /> {!relatedTo.ZipCode__c}<br /> <br /> </p> <p> <b>Compléments d'informations:</b></p> <br /> </td> <td style="width: 300px;"> <p> <b>No DE RETOUR:</b> {!relatedTo.AOM_Returns_Price_Adjustment_Order_No__c}</p> </td> </tr> <tr style="height: 107.55pt; text-align: center;"> <td> <p><b> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '02 - Compans'}"> SPICERS<br /> ZAC du parc de Compans<br /> Rue Louis Blériot<br /> 77290 COMPANS </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '03 - Tours'}"> SPICERS<br /> 11 rue du Général Mocquery<br /> BP 153 - ST Avertin<br /> 37171 Chambray-les Tours Cedex </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '06 - Bordeaux'}"> SPICERS<br /> RUE FRANCIS GARNIER<br /> ZI ALFRED DANEY<br /> 33028 BORDEAUX CEDEX </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '07 - Toulouse'}"> SPICERS<br /> PARC INDUSTRIEL EURONORD<br /> 3 RUE GUTEMBERG<br /> 31150 BRUGUIERES </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '08 - Valence'}"> SPICERS<br /> RUE DU COMMANDANT COUSTEAU<br /> BP 21<br /> 26801 PORTES LES VALENCES </apex:outputPanel> </b></p> </td> </tr> </table> </body> </html> </messaging:htmlEmailBody> <messaging:plainTextEmailBody > Cher client Chère cliente Veuillez trouvez ci-dessous votre balise de retour à compléter et à coller impérativement sur votre colis. La liste des produits ci-dessous récapitule vos déclarations enregistrées sous le numéro de dossier : {!relatedTo.AOM_Returns_Price_Adjustment_Order_No__c} Sincères salutations, {!relatedTo.Owner.Name} Le service client Spicers France BALISE DE REPRISE A COLLER IMPERATIVEMENT SUR LE SUR-EMBALLAGE DE VOTRE COLIS N° de Compte et Nom du Client: {!relatedTo.Account_Number__c} {!relatedTo.Account__r.Name} Nom et Adresse de l'enlèvement : {!relatedTo.Name1__c} {!relatedTo.Name2__c} {!relatedTo.Street1__c} {!relatedTo.Street2__c} {!relatedTo.Street3__c} {!relatedTo.City__c} {!relatedTo.ZipCode__c} Compléments d'informations: N° DE RETOUR: {!relatedTo.AOM_Returns_Price_Adjustment_Order_No__c} <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '02 - Compans'}"> SPICERS ZAC du parc de Compans Rue Louis Blériot 77290 COMPANS </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '03 - Tours'}"> SPICERS 11 rue du Général Mocquery BP 153 - ST Avertin 37171 Chambray-les Tours Cedex </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '06 - Bordeaux'}"> SPICERS RUE FRANCIS GARNIER ZI ALFRED DANEY 33028 BORDEAUX CEDEX </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '07 - Toulouse'}"> SPICERS PARC INDUSTRIEL EURONORD 3 RUE GUTEMBERG 31150 BRUGUIERES </apex:outputPanel> <apex:outputPanel rendered="{!relatedTo.Account__r.Logistics_RDC__c == '08 - Valence'}"> SPICERS RUE DU COMMANDANT COUSTEAU BP 21 26801 PORTES LES VALENCES </apex:outputPanel> </messaging:plainTextEmailBody> </messaging:emailTemplate>

 

 

 

AKallAKall

Hi Everyone,

I made the original post above. At moment that post is not a concern for me because I have the emails working fine as txt emails. However, I have recently encountered a similar problem that I got personal help from salesforce support with for a few weeks. They could not figure out the problem and suggested I either purchase premium support or post to the boards. So here it goes...

 

I have a visualforce email template that gets sent by a trigger. The trigger is built to send an email based on one condition, and there two different ways to meet that condition (ie the order of the steps taken by user to meet the condition). The email is fine when the condition is met one way, but it arrives blank when met the second way.

 

I first built this trigger before the release of Summer 09. At that time the problem was the same in both my Sandbox and my production environment. However, now that Summer 09 is live in the sandbox I no longer have the problem in the sandbox. So I am keeping my fingers crossed that once it is released in the live environment my worries will be over. This seems to be something similar to what Chris described above.

ccopekccopek

Guy,

 

I've set up a similar scenario as yours in my test org, and cannot reproduce the problem.  Can you provide me with a little more information:

 

1).  The Specific Workflow Rule Name/Id that is triggering the email action (I'm looking at one of your workflow rules that has a Time Based Email Action.  Since that email action is sent from a batch process, I would not think that it would make a difference if the update was done through Apex Code or manually on the object).

2).  Is see you have a Trigger on your custom object that sends an email before update of the object.  Is there any chance that is the email you are having problems with?  I notice that you have an if condition for retrieving the Owner of the custom object, using data from the Owner to populate some of the email data.  If that condition is not met, you will get a NullPointerException when trying to populate the first mail field (mail.setReplyTo()) using the owner's email.  I suspect this is not your problem, because the email simply won't be sent out if the NullPointerException occurs.  I believe you said you are getting the email with no body, but I thought I would point this out.

3).  Can you point me to the Apex Code that is doing the update that triggers the workflow email action and describe the action you perform to execute the apex code (perhaps it's a VF controller that is called from an action on a VF page).

 

Chris

GuyClairboisGuyClairbois

Hi everybody,

we just moved from Spring 09 to Summer 09 on our Sandbox and on Production and guess what: On Sandbox the problem is fixed!

 

So I'm assuming this will also happen on Production, but will only be able to tell next Thursday when a new batch of records is generated on Production.

ccopekccopek

Great to hear Guy.  Let me know if you experience any problems with the batch of records that are generated Thursday in production.

 

Chris 

 

ccopekccopek

David,

 

I took a look at what you have set up in your org, and nothing stands out as a problem.  Let me know what results you find when you try to reduce the code in the template, and I will take another look.

 

Chris

AKallAKall
It looks like the release of Summer 09 has solved my problem!
This was selected as the best answer
GuyClairboisGuyClairbois

Confirmed. Summer '09 solved the problem on our Live environment as well.

Thanks for your help,

Guy

AKallAKall

Hey guys,

I'm still encoutering a problem. I just released a new workflow rule that sends a VF email on a Time Based Trigger. As usual, the email works fine in the Sandbox, but arrives blank in production. Unfortunately, this is a very high priority for me now.

ccopekccopek

AKall,

 

Can you provide the following information and I will take a look:

 

- Your production OrgId

- Workflow Rule and Email Action that are triggering the email that is sent blank

 

 I will try to set something similar up in a test org and see if I can figure out what's going wrong.

 

Chris

ramya patil_KVPramya patil_KVP

Hi,

 

We too facing the same issue that we(Approvers) are receiving blank email when some one submit a record for approval.

And our email template is coded in visualforce.

 

We are getting this blank email along with the email which is in the correct format.But this blank one is as extra we are getting.

 

Can any one please help to understand why are we receiving blank emails.

 

*****This is on very high priority for us *****

 

jayasuriya janarthanjayasuriya janarthan
Can anyone please reply for the above scenario?
PV TPV T
I am also facing this issue. No clue so far what is the reason behind it. working fine for many one but for some it get blank but not consistent so far.
Anyone can helpout to find the issue it will be very helpful.