2

When dealing with cases with a lot of emails, our Customer Service agents sometimes have to click on every email on a case to read the whole conversation. (They don't use the console yet.) It would be much faster if all the emails (including the attachments) would be shown on a single page.

I am thinking of a button + Visualforce page that lists all emails with subject, to/from, date, text and links to attachments in chronological order. Does anyone know a free app on the app exchange that does that (I did not find one)? Has someone already written a page for this requirement? That would be a great quick fix.

3

You can solve this with a button + VF page + VF extension (you need it for sorting emails and for getting the attachments). This solution shows first a list of all the attachments in the emails, then lists the emails descending by the message date. Our Customer Care Agents are raving about this ;)

1. Create the VF page (with reference to the extension):

<apex:page standardController="Case" title="Case Number: {!Case.CaseNumber}" extensions="CaseEmailExtension">

ATTACHMENTS list sorted descending by created date

<apex:pageBlock title="Case Number: {!Case.CaseNumber}">
<h1>Attachments:</h1><br/>
<apex:repeat value="{!attachments}" var="att">
<apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z} ">
        <apex:param value="{!att.CreatedDate}" />
    </apex:outputText>:
<a href="/{!att.Id}">{!att.Name}</a><br/>
</apex:repeat>
</apex:pageBlock>
<br/>

EMAILS formatted in a table

<apex:repeat value="{!sortEmails}" var="email">
<apex:pageBlock >
<apex:facet name="header">
    <apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z}" style="font-weight:bold;font-style:italic;font-size:15px;float:left">
        <apex:param value="{!email.MessageDate}" />
    </apex:outputText>
</apex:facet>
<table width="100%">
    <tr>
        <td width="70%" align="left">
            <table cellpadding="2px">
                <tr>
                    <td width="50px" align="right"><b>From: </b></td>
                    <td align="left"><i><apex:outputText value="{!email.FromAddress}"/></i></td>
                </tr>
            </table>
        </td>
        <td width="30%" align="right">
            <b>{!IF(email.Incoming,"INCOMING", "OUTGOING")}</b>
        </td>
    </tr>
    <tr>
        <td width="70%" align="left">
            <table cellpadding="2px">
                <tr>
                    <td width="50px" align="right"><b>To: </b></td>
                    <td align="left"><i><apex:outputText value="{!email.ToAddress}"/></i></td>
                </tr>
            </table>
        </td>
        <td width="30%" align="right"><b>{!IF(email.HasAttachment,"with Attachment", "")}</b></td>
    </tr>
    <tr>   
        <td width="70%" align="left">
            <table cellpadding="2px">
                <tr>
                    <td width="50px" align="right"><b>BCC: </b></td>
                    <td align="left"><apex:outputText value="{!email.BccAddress}"/></td>
                </tr>
            </table>
        </td>
        <td width="30%" align="right">
        </td>
    </tr>
    <tr>   
        <td width="70%" align="left">
            <table cellpadding="2px">
                <tr>
                    <td width="50px" align="right"><b>Subject: </b></td>
                    <td align="left"><apex:outputText value="{!email.Subject}"/></td>
                </tr>
            </table>
        </td>
        <td width="30%" align="right">
            <table cellpadding="2px">
                <tr>
                    <td width="80px" align="right"><b>Created by: </b></td>
                    <td align="left"><i><apex:outputText value="{!email.CreatedBy.Name}"/></i></td>
                </tr>
            </table>
        </td>
    </tr>
    </table>
<br/>
<br/>
    <table>
    <tr>   
        <td width="70%" align="left">
            <table cellpadding="2px">
                <tr>
                    <td width="50px" align="right"><b></b></td>
                    <td align="left"><apex:outputField value="{!email.TextBody}"/></td>
                </tr>
            </table>
        </td>
        <td width="30%" align="right">
            <table cellpadding="2px">
                <tr>
                    <td width="80px" align="right"><b></b></td>
                    <td align="left"><i></i></td>
                </tr>
            </table>
        </td>
    </tr>
</table><br/>


<!—-in our case attachments are not needed at the separate emails
<apex:repeat value="{!email.Attachments}" var="attachment">
<a href="/{!attachment.Id}">{!attachment.Name}</a>
</apex:repeat>-->

</apex:pageBlock>
</apex:repeat>
</apex:page>

2. Create the extension to sort the emails and add the attachments:

public with sharing class CaseEmailExtension {

  private final Case currentCase;


  public CaseEmailExtension(ApexPages.StandardController currentcase) {
    this.currentCase = (Case)currentcase.getRecord();
  }

  public List<EmailMessage> getSortEmails(){
    List <EmailMessage> sortedEmails = new List<EmailMessage>();
    sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, MessageDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name //, (Select Id, Name from Attachments) --> attachments are not needed at the separate emails  
            from EmailMessage where ParentId =: currentCase.Id 
            order by MessageDate DESC ];
    return sortedEmails;
  }

  public List<Attachment> getAttachments() {
    List<Attachment> attachments = new List<Attachment>();
    attachments = [SELECT Id, Name, Body, CreatedDate
            from Attachment
            where ParentId in (SELECT Id from EmailMessage where ParentId =: currentCase.Id)
            order by CreatedDate DESC]; //sorting the emails by message date descending
    return attachments;  
  }
}

3. Create the button what shows the VF page

4. Add the button to the page layout

The result looks like this (except the white parts ;)): enter image description here

|improve this answer|||||
  • No problem, Georg! :) – detti Jul 10 '14 at 8:32
  • By any chance do you have the test code ? This is super creative and my team would kill for it.... – Kevin Nov 21 '14 at 0:39
0

This is not a free app, but it is not all that costly considering the capability.

Disclaimer: I do not work for, or have any vested interest in this app, just have implemented it a few times and thought it had some useful capabilities.

Email to case premium

https://appexchange.salesforce.com/listingDetail?listingId=a0N30000001R5cyEAC

has some of the functionality that you are looking for.

They do some interesting things, by taking all email and stripping unnecessary text (long back and forth threads) and show them neatly in chronological order in the case comments. This is their base package.

They also offer what they refer to as the 'Presentation layer', which is really a VF page that does exactly what you are talking about. This isn't mentioned or shown in the base package, you would need to contact a rep to get a demo for that. You can show emails, and tracked field changes and really whatever information you want, in chronological order. They offer some neat flagging customization in there as well if you like. Have seen orgs use this as a solution to having one place to have post mortem analysis on cases, and this provided a single view of exactly how the case progressed from open until closure.

Once again, no affiliation at all with the app, just thought I would suggest it as it seems to be what you are looking for, besides the fact that it isn't free, but you are looking for some pretty serious customization, so the chances of finding that for free are slim.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.