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
Dave FarringtonDave Farrington 

<apex:relatedList> for Emails on Cases

Best Answer chosen by Dave Farrington
Dave FarringtonDave Farrington
Hi Vinit,

Thank you, it has helped me a lot. Though I changed the code into a pageblocktable that looks a lot nicer on a visualforce page and linked the email subject so you can click into the email to see what it was. Below is the code I used:

<apex:pageBlock >
<apex:pageBlockTable value="{!Case.EmailMessages}" var="email"  onRowClick="clickElem(this);" styleClass="caseId">
<apex:column value="{!email.MessageDate}" headerValue="Message Date and Time" />
    <apex:column headerValue="Subject" >
   <apex:outputLink value="/{!email.Id}"><apex:outputText value="{!email.Subject}" /></apex:outputLink>
</apex:column>
    <apex:column value="{!email.FromName}" headerValue="From Name"  />
    <apex:column value="{!email.FromAddress}" headerValue="From Address"  />
</apex:pageBlockTable>
</apex:pageBlock>

All Answers

Vinit_KumarVinit_Kumar
Hey Dave,

Can you elaborate what you are looking for ??
Dave FarringtonDave Farrington
Thanks Vinit, I have created a visualforce page based on the standard controller (case), and have created a few related lists on this page. However the one that has stumped me is emails; this is a related list on our standard case view. I cannot duplicate this on the visualforce page I have created. Any ideas on solving this?
Vinit_KumarVinit_Kumar
Unfortunately EmailMessages related list is not supported in <apex:relatedlist> as of now.However,you can create a Datatable and fetch the related list values like below :-

<apex:dataTable value="{!Case.EmailMessages}" var="email">
    <apex:column value="{!email.Subject}" />
    <apex:column value="{!email.ToAddress}" />
</apex:dataTable>

If this helps,please mark it as best answer to help others :)
Dave FarringtonDave Farrington
Hi Vinit,

Thank you, it has helped me a lot. Though I changed the code into a pageblocktable that looks a lot nicer on a visualforce page and linked the email subject so you can click into the email to see what it was. Below is the code I used:

<apex:pageBlock >
<apex:pageBlockTable value="{!Case.EmailMessages}" var="email"  onRowClick="clickElem(this);" styleClass="caseId">
<apex:column value="{!email.MessageDate}" headerValue="Message Date and Time" />
    <apex:column headerValue="Subject" >
   <apex:outputLink value="/{!email.Id}"><apex:outputText value="{!email.Subject}" /></apex:outputLink>
</apex:column>
    <apex:column value="{!email.FromName}" headerValue="From Name"  />
    <apex:column value="{!email.FromAddress}" headerValue="From Address"  />
</apex:pageBlockTable>
</apex:pageBlock>

This was selected as the best answer
Vinit_KumarVinit_Kumar
Happy to help Dave :)

Please mark it as best answer to help others :)
Jos Vervoorn 2Jos Vervoorn 2
Hi Dave, have you managed to get this working as i'm following the same trail (close to) ... and get a case email related list.