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
Mathew Andresen 5Mathew Andresen 5 

First time I run process email is blank, second time email has data

Hi,

This is really wierd.  I have an action that triggers a summary email to be sent when triggered.  The first time I click the action button the email gets sent but is blank.  The second time I click it the email is sent but has data in it.  I can't think what could possibly cause behavior like that.

This is the section
try {
        PageReference displayPage = page.BottlingSummaryEmail_page;
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {}; 
		toAddresses.add(userEmail);

        Blob body;
        string htmlBody;
        try {
            // returns the output of the page as a blob
            body = displayPage.getContent();
            system.debug('body should be fine');
            // need to pass unit test -- current bug    
            } catch (VisualforceException e) {
                system.debug('in the catch block');
                 body = Blob.valueOf('Some Text');
            }
        htmlBody = body.toString();
        email.setHtmlBody(htmlBody);
        email.setToAddresses(toAddresses);  
     	email.setSubject('Bottling Summary for '); // + dateString);            
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        } catch (exception e) { system.debug ('TastingRecap_class *** error in the send email and error = ' + e);}

of code where I send the summary email (I can provide the rest if needed)


and here is the visualforce page I call for the tempalte
 
<apex:repeat value="{!botLotMap}" var="shift">
        
   <h1>  Bottling Summary for Shift {!shift} </h1>
        <table width="100%">
            
      
       <th>Shift</th><th>Change Over</th><th>Operation</th> <th>Client</th><th>Brand</th><th>Cases</th><th>Cases per Hour</th><th>Notes</th>
        <apex:repeat value="{!botLotMap[shift]}" var="v" >
       
            <tr>
            <td><apex:outputtext value="{!botLotMap[shift][v].Bottling_Shift__r.Bottling_Shift__c}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Type_of_Changeover__c}"  />  </td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Labeled_Bottled__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Client_Lookup__r.name}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Brand__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Actual_Bottled__c}"/> </td>           
            <td><apex:outputtext value="{!botLotMap[shift][v].Cases_Per_Hour__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Notes__c}"/></td>
            </tr>

            
        </apex:repeat>  
            <tr><td colspan="4">Total</td><td>{!totalCasesBottled[shift]}</td><td></td><td></td><td></td></tr>
        </table>
    </apex:repeat>
  
    
</apex:page>

Thanks,
 
Best Answer chosen by Mathew Andresen 5
LakshmanLakshman
I have done a sample POC for this and it seems like the state of the botLogMap is not getting set, this something we need to ask to Salesforce Support. Below is my POC code done for Contact:
VF - SendPageAsEmail
<apex:page standardController="Account" extensions="PageAsEmail">
  <apex:form >
  <apex:pageblock >
      <apex:commandButton value="Send Email" action="{!sendClientEmail}"/>
  </apex:pageblock>
  </apex:form>
</apex:page>

Apex Class 
public class PageAsEmail {
    public Account accountObj {get;set;}
    String accountId;
    public List<Contact> listofContacts {get;set;}
    public Map<String, Map<String,COntact>> botLotMap {get;set;}
    public PageAsEmail(ApexPages.StandardController std) {
       accountId = ApexPages.currentPage().getParameters().get('id');
       if (accountId != NULL) {
           accountObj = [Select Id, Name, AccountNumber from Account where Id =: accountId];
           getContacts();
       } else {
           accountObj = new Account();
       }
       

 
    }
    
    public void getContacts() {
        listofContacts = [Select Id, Name, FirstName, LastName, EMail,AccountId,Phone from COntact where AccountId=: accountObj.Id];
    }
    
    public void sendClientEmail() {
        botLotMap = new Map<String, Map<string, COntact>>();
        for (Contact bot: listofContacts) {

            if(!botLotMap.containsKey(bot.AccountId)) {
                botLotMap.put(bot.AccountId, New Map<string, Contact>());
                
             }
            botLotMap.get(bot.AccountId).put(bot.id, bot);
            
         }
        
        PageReference displayPage = page.PageAsEmail;
        displayPage.setRedirect(false);
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {}; 
        toAddresses.add(UserInfo.getUserEmail());
        
        system.debug('botlotmap in the summary = ' + botLotMap);
        Blob body;
        string htmlBody;
        
        
        body = displayPage.getContent();
        system.debug('body should be fine');
            
            
        htmlBody = body.toString();
        email.setHtmlBody(htmlBody);
        email.setToAddresses(toAddresses);  
        email.setSubject('Bottling Summary for ' + accountObj.Name); // + dateString);            
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
    }
    
}

VF Page
<apex:page standardController="Account" extensions="PageAsEmail">
    <h1>
        Bottling Summary for &nbsp; {!accountObj.Name}
    </h1>
    
    <br/>

 
    
   <style type="text/css"> table, th, td { border: 1px solid black; } </style>
   
    <apex:repeat value="{!botLotMap}" var="shift">
        
   <h1>  Bottling Summary for Shift {!shift} </h1>
        <table width="100%">
            
      
       <th>
           <td>First Name</td>
           <td>Last Name</td>
           <td>Email</td>
           <td>Phone</td>
       </th>
        <apex:repeat value="{!botLotMap[shift]}" var="v" >
       
            <tr>
                <td><apex:outputtext value="{!botLotMap[shift][v].FirstName}" /></td>
                <td><apex:outputtext value="{!botLotMap[shift][v].LastName}"  />  </td>
                <td><apex:outputtext value="{!botLotMap[shift][v].Email}"/></td>
                <td><apex:outputtext value="{!botLotMap[shift][v].Phone}" /></td>
            </tr>

            
        </apex:repeat>  
            
        </table>
    </apex:repeat>
  
</apex:page>

Another workaround which I can suggest is create Visualforce email template and use a component inside the template to generate your body dynamically. Please follow my answer to this blog post for the sample code - https://developer.salesforce.com/forums/ForumsMain?id=906F0000000D6IfIAK

In the template there you wont have to send as attachment but as a body so just your template would look like below:
<messaging:emailTemplate subject="Opportunity '{!relatedTo.Name}' Detail with Products" recipientType="User"
        relatedTo="opportunity >
<messaging:htmlEmailBody >
Hi {!relatedTo.Owner.name} ,<br/>
your opportunity '{!relatedTo.Name}' has beed closed won.<br/>
Please find their products detail as below.
<br/>
<c:OpptyProduct opportunityId="{!relatedTo.Id}"></c:OpptyProduct><!--gives the reference of the component-->
</messaging:htmlEmailBody>
 

 
</messaging:emailTemplate>

Hope it helps.

All Answers

Mathew Andresen 5Mathew Andresen 5
The problem seems to be in the visualforce page.  If I comment everything out and just put some simple text that shows up first time I run it
Mathew Andresen 5Mathew Andresen 5
For some reason the data in {!botLotMap} seems to show up in the 2nd run in the VF page, but not the first.  I've checked the debug logs, and BotLotMap seems to have data in both runs...
LakshmanLakshman
how is the botLotMap is getting set ? Can you share the complete code ?
Mathew Andresen 5Mathew Andresen 5
Complete Bottling Day class
public class BottlingDay_Class {
    
    String botDayId;
    public Bottling_Day__c BotDay {get; set; }
    Bottling_Shift__c botShift;
    public List<Bottling_Shift__c> botShiftList {get; set; }
    public String selectedListID { get; set {selectedListID = value; } }
    public List<Bottling_Lot__c> botLotList {get; set; }
    public Map<String, Map<string, Bottling_Lot__c>> botLotMap {get; set;}
    public Map<String, Decimal> totalCasesBottled {get; set;}
    String userEmail = UserInfo.getUserEmail();
    
public BottlingDay_Class(ApexPages.StandardController std) {
        botDayId = ApexPages.currentPage().getParameters().get('id');
        
        if (botdayId != NULL) {
            botDay = [SELECT Id, Bottling_Date__c, 
                      Total_Bottled__C, 
                      Total_Hours__C, 
                      Cases_Per_Hour__C,
                      Adj_Cases_Per_Hour__c,
                      Total_ChangeOver_Time__c,
                      Bottles_Per_Minute__C 
                      FROM Bottling_Day__c WHERE Id = :botDayId]; //
             
              makeBotShiftList();
              makeBotLotList();
                     
        } else {
            botDay = new Bottling_Day__c();
        }
    } // end the constructor
    
    
    public PageReference addShift() {
        upsert(botDay);
        botDayId = botDay.id;
        Bottling_Shift__c botShift = new Bottling_Shift__c(Bottling_Day__C = botDayId);
        PageReference page = new PageReference('/apex/BottlingShift_Page?botDayId=' + botDayId);
        page.setRedirect(true);
        return page;
        
        
    }
    
    public PageReference editShift() {
        PageReference page = new PageReference('/apex/BottlingShift_Page?id=' + selectedListId);
        page.setRedirect(true);
        return page;
    }
    
    public void delShift() {
        botShift = [SELECT Id FROM Bottling_Shift__c WHERE id = :selectedListId];
        delete (botShift);
        makeBotShiftList();
 
    }
    
    public void makeBotShiftList() {
          botShiftList = [SELECT Id,
                            Bottling_Shift__c,
                            Cases_Per_Hour__c,
                            Total_Bottled__c,
                            Total_Hours__c,
                            notes__C,
                            Total_Slowdown_Minutes__c,
                            Total_Stoppage_Minutes__c
                            FROM Bottling_Shift__c WHERE Bottling_Day__c = :botDayID];
        
    }
    
    public void makeBotLotList() {
        botLotList = [SELECT Bottling_Shift__r.Bottling_Shift__c, Bottling_Shift__c,
                          Type_of_Changeover__c,
                          Labeled_Bottled__c, 
                          Bottling_Shift__r.Bottling_Day__r.Bottling_Date__c,
                          Brand__c,
                          Bulk_Balance_Remaining__c,
                          Varietal__c,
                          Wine_Code__c,
                          Finished_Code__c,                          
                          Scheduled_Cases__c, 
                          Estimated_Hours__c,                             
                          Start_Time__c,
                          End_Time__c,
                          Actual_Hours__c,
                          Variance_Hours__c,
                          Actual_Bottled__c,
                          Cases_Per_Hour__c,
                          Bottles_Per_Minute__c,
                          Notes__c,
                          Total_Slowdown_Minutes__c,
                          Total_Stoppage_Minutes__c,
                      	  Client_lookup__c,
                          client_lookup__r.name,
                          client_lookup__r.owner.name,
						  client_lookup__r.owner.email
                          FROM Bottling_Lot__c WHERE Bottling_Shift__r.Bottling_Day__r.id = :botDay.id];
 
    }
    
    public void sendClientEmail() {
       
        
        Set<String> repSet = new set<String>();
        map<String, Map<string, Bottling_Lot__c>> repMap = new map<String, Map<string, Bottling_Lot__c>>(); // email <account Id, bottling lot>
        Map<string, Bottling_Lot__c> acctMap;
        
        // build a set of all the owner Id that will have to be emailed        
        if (botLotList.size() > 0) {
            for (Bottling_Lot__c bot:botLotList) {  
                repSet.add(bot.client_lookup__r.owner.email);
            }
            for (String s:repSet) {
                acctMap = new map<String, Bottling_lot__c>();
                for (Bottling_Lot__c bot:botLotList) { 
                    if (s == bot.client_lookup__r.owner.email) {
                        acctMap.put(bot.client_lookup__c, bot);
                    }
                 }
                repMap.put(s, acctMap);
             }
            system.debug('repMap = ' + repMap);
         }
        
        for (String repEmail:repMap.keySet()) {
            if (repEmail != NULL) {
                acctMap = repMap.get(repEmail);
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();        
                String[] toAddresses = new String[] {}; 
                toAddresses.add(repEmail);
                String dateString;
                String body = '';
                body+= '<style type="text/css"> table, th, td { border: 1px solid black; } </style>';
                body+= '<p>Hello, <br/> The following items were bottled for your clients. </p>';
                body+= '<table with = "100%" align="left">';
                body+= '<tr> <th>Date </th> <th>Account</th> <th>Brand</th><th>Varietal</th><th>Finished Case Code</th><th>Cases</th> <th>Notes</th></tr>';
                for (Bottling_Lot__c bot:acctMap.values()) {
                    date myDate = bot.Bottling_Shift__r.Bottling_Day__r.Bottling_Date__c;
                    dateString = myDate.format();
                    body+= '<tr>' +
                            '<td>' + dateString + '</td>' +
                            '<td>' +  bot.Client_lookup__r.name + '</td>' +
                            '<td>' + bot.brand__c + '</td>' +
                            '<td>' + bot.varietal__c + '</td>' + 
                        	'<td>' + bot.Finished_Code__c + '</td>' +
                            '<td>' + bot.Actual_Bottled__c + ' </td>' +
                            '<td>' + bot.Notes__c + '</td>' +
                        '</tr>';
                 }
                body+= '</table>';
                system.debug('BottlingDay_Class *** - toAddresses ' + toAddresses);
                email.setToAddresses(toAddresses);
                
                email.setSubject('Bottling report for ' + dateString);
                email.setHtmlBody(body);
                try {
                if (toAddresses.size() > 0) { Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  }
                } catch (exception e) { system.debug('BottlingDay_Class *** - error sending email ' + e);}
            }
        } // end the for loop


    
    // send the summary email
    botLotMap = new Map<String, Map<string, Bottling_Lot__c>>();
    totalCasesBottled = new Map<String, Decimal>();    
        for (Bottling_Lot__c bot:botLotList) {
            if(!botLotMap.containsKey(bot.Bottling_Shift__r.Bottling_Shift__c)) {
                botLotMap.put(bot.Bottling_Shift__r.Bottling_Shift__c, New Map<string, Bottling_Lot__c>());
                totalCasesBottled.put(bot.Bottling_Shift__r.Bottling_Shift__c, bot.Actual_Bottled__c);
             }
            botLotMap.get(bot.Bottling_Shift__r.Bottling_Shift__c).put(bot.id, bot);
            Decimal cases = 0;
            if(totalCasesBottled.get(bot.Bottling_Shift__r.Bottling_Shift__c) !=NULL) {cases = totalCasesBottled.get(bot.Bottling_Shift__r.Bottling_Shift__c); }
            if (bot.Actual_Bottled__c != NULL) {cases +=bot.Actual_Bottled__c;}
            totalCasesBottled.put(bot.Bottling_Shift__r.Bottling_Shift__c, cases);
         }
        system.debug('BottlingDay_Class *** - totalCasesBottled= ' + totalCasesBottled);
        system.debug('BottlingDay_Class *** - botLotMap= ' + botLotMap);
        
        
        
 try {
        PageReference displayPage = page.BottlingSummaryEmail_page;
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {}; 
		toAddresses.add(userEmail);
     	toAddresses.add('ylal@salesforce.com');
		system.debug('botlotmap in the summary = ' + botLotMap);
        Blob body;
        string htmlBody;
        try {
            // returns the output of the page as a blob
            body = displayPage.getContent();
            system.debug('body should be fine');
            // need to pass unit test -- current bug    
            } catch (VisualforceException e) {
                system.debug('in the catch block');
                 body = Blob.valueOf('Some Text');
            }
        htmlBody = body.toString();
        email.setHtmlBody(htmlBody);
        email.setToAddresses(toAddresses);  
     	email.setSubject('Bottling Summary for '); // + dateString);            
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        } catch (exception e) { system.debug ('TastingRecap_class *** error in the send email and error = ' + e);}
        
        
        
    } // end the send email method

}
Mathew Andresen 5Mathew Andresen 5
I put the data into botLotMap starting at line 166.  Basically I take the botLotList (a list of all the items that are bottled for the day) and then use a map to break it up into a map of bottling lot's by shift

 
LakshmanLakshman
can you check if you are getting anything in htmlBody ? 
Does BottlingSummaryEmail_page accept any parameter like id or something ? when you hit that page directly using /apex/BottlingSummaryEmail_page does it show you any data ?
Can you try doing this-
PageReference pdf = Page.BottlingSummaryEmail_page;
pdf.getParameters().put('id', recordId);  //set parameters if required      
pdf.setRedirect(true);
Blob pageContent = pdf.getContent();
String htmlBody = (String)pageContent;
email.setHtmlBody(htmlBody);

 
LakshmanLakshman
you can also use pageContent.toString() if you get Cast exception.
 
Mathew Andresen 5Mathew Andresen 5
I am getting data in HTMLbody, but the first time I run it it's missing the data that would occur in botLotMap, the second time it's there.

the BottlingSummaryEmail_page doesn't take any parameters.  It just gets the data from the BotDay controller.  So if I hit the page directly there is no data to show.  I tried as you suggested, but still no data the first time, but data the second.  Note that (String)pageContent didn't work, it produced an error
 
pdf.setRedirect(true);
Blob pageContent = pdf.getContent();
String htmlBody = pageContent.toString(); //String htmlBody = (String)pageContent;  this produces an error
email.setHtmlBody(htmlBody);



 
LakshmanLakshman
can you attach debug log after you hit the sendClientEmail() method ?
Mathew Andresen 5Mathew Andresen 5
Sure here is a link to the logs in dropbox (It's not possible to embded in the forums I don't think)

https://www.dropbox.com/sh/405650trfncq9cz/AACLHrNMEi8mdTZNKQzjeaVda?dl=0
 
LakshmanLakshman
The BottlingSummaryEmail_page has same controller - BottlingDay_Class ?
Mathew Andresen 5Mathew Andresen 5
yes

full code for the page below
 
<apex:page standardController="Bottling_Day__c" extensions="BottlingDay_Class">

    <h1>
        Bottling Summary for &nbsp; <apex:outputtext value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!botDay.Bottling_Date__c}"/> </apex:outputtext>
    </h1>
    
    <br/>

 
    
   <style type="text/css"> table, th, td { border: 1px solid black; } </style>
   
    <apex:repeat value="{!botLotMap}" var="shift">
        
   <h1>  Bottling Summary for Shift {!shift} </h1>
        <table width="100%">
            
      
       <th>Shift</th><th>Change Over</th><th>Operation</th> <th>Client</th><th>Brand</th><th>Cases</th><th>Cases per Hour</th><th>Notes</th>
        <apex:repeat value="{!botLotMap[shift]}" var="v" >
       
            <tr>
            <td><apex:outputtext value="{!botLotMap[shift][v].Bottling_Shift__r.Bottling_Shift__c}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Type_of_Changeover__c}"  />  </td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Labeled_Bottled__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Client_Lookup__r.name}" /></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Brand__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Actual_Bottled__c}"/> </td>           
            <td><apex:outputtext value="{!botLotMap[shift][v].Cases_Per_Hour__c}"/></td>
            <td><apex:outputtext value="{!botLotMap[shift][v].Notes__c}"/></td>
            </tr>

            
        </apex:repeat>  
            <tr><td colspan="4">Total</td><td>{!totalCasesBottled[shift]}</td><td></td><td></td><td></td></tr>
        </table>
    </apex:repeat>
  
   
</apex:page>



 
LakshmanLakshman
I have done a sample POC for this and it seems like the state of the botLogMap is not getting set, this something we need to ask to Salesforce Support. Below is my POC code done for Contact:
VF - SendPageAsEmail
<apex:page standardController="Account" extensions="PageAsEmail">
  <apex:form >
  <apex:pageblock >
      <apex:commandButton value="Send Email" action="{!sendClientEmail}"/>
  </apex:pageblock>
  </apex:form>
</apex:page>

Apex Class 
public class PageAsEmail {
    public Account accountObj {get;set;}
    String accountId;
    public List<Contact> listofContacts {get;set;}
    public Map<String, Map<String,COntact>> botLotMap {get;set;}
    public PageAsEmail(ApexPages.StandardController std) {
       accountId = ApexPages.currentPage().getParameters().get('id');
       if (accountId != NULL) {
           accountObj = [Select Id, Name, AccountNumber from Account where Id =: accountId];
           getContacts();
       } else {
           accountObj = new Account();
       }
       

 
    }
    
    public void getContacts() {
        listofContacts = [Select Id, Name, FirstName, LastName, EMail,AccountId,Phone from COntact where AccountId=: accountObj.Id];
    }
    
    public void sendClientEmail() {
        botLotMap = new Map<String, Map<string, COntact>>();
        for (Contact bot: listofContacts) {

            if(!botLotMap.containsKey(bot.AccountId)) {
                botLotMap.put(bot.AccountId, New Map<string, Contact>());
                
             }
            botLotMap.get(bot.AccountId).put(bot.id, bot);
            
         }
        
        PageReference displayPage = page.PageAsEmail;
        displayPage.setRedirect(false);
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {}; 
        toAddresses.add(UserInfo.getUserEmail());
        
        system.debug('botlotmap in the summary = ' + botLotMap);
        Blob body;
        string htmlBody;
        
        
        body = displayPage.getContent();
        system.debug('body should be fine');
            
            
        htmlBody = body.toString();
        email.setHtmlBody(htmlBody);
        email.setToAddresses(toAddresses);  
        email.setSubject('Bottling Summary for ' + accountObj.Name); // + dateString);            
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
    }
    
}

VF Page
<apex:page standardController="Account" extensions="PageAsEmail">
    <h1>
        Bottling Summary for &nbsp; {!accountObj.Name}
    </h1>
    
    <br/>

 
    
   <style type="text/css"> table, th, td { border: 1px solid black; } </style>
   
    <apex:repeat value="{!botLotMap}" var="shift">
        
   <h1>  Bottling Summary for Shift {!shift} </h1>
        <table width="100%">
            
      
       <th>
           <td>First Name</td>
           <td>Last Name</td>
           <td>Email</td>
           <td>Phone</td>
       </th>
        <apex:repeat value="{!botLotMap[shift]}" var="v" >
       
            <tr>
                <td><apex:outputtext value="{!botLotMap[shift][v].FirstName}" /></td>
                <td><apex:outputtext value="{!botLotMap[shift][v].LastName}"  />  </td>
                <td><apex:outputtext value="{!botLotMap[shift][v].Email}"/></td>
                <td><apex:outputtext value="{!botLotMap[shift][v].Phone}" /></td>
            </tr>

            
        </apex:repeat>  
            
        </table>
    </apex:repeat>
  
</apex:page>

Another workaround which I can suggest is create Visualforce email template and use a component inside the template to generate your body dynamically. Please follow my answer to this blog post for the sample code - https://developer.salesforce.com/forums/ForumsMain?id=906F0000000D6IfIAK

In the template there you wont have to send as attachment but as a body so just your template would look like below:
<messaging:emailTemplate subject="Opportunity '{!relatedTo.Name}' Detail with Products" recipientType="User"
        relatedTo="opportunity >
<messaging:htmlEmailBody >
Hi {!relatedTo.Owner.name} ,<br/>
your opportunity '{!relatedTo.Name}' has beed closed won.<br/>
Please find their products detail as below.
<br/>
<c:OpptyProduct opportunityId="{!relatedTo.Id}"></c:OpptyProduct><!--gives the reference of the component-->
</messaging:htmlEmailBody>
 

 
</messaging:emailTemplate>

Hope it helps.
This was selected as the best answer
Mathew Andresen 5Mathew Andresen 5
Yes, I have contacted SF premier support.  I think something might be wrong on their end.  Thanks for the work around I will look at implementing that.