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
Shubh2910Shubh2910 

Show Profile Picture on Visualforce Email Template

Hi All,

I am trying to show the user Profile Picture of Salesforce in Visualforce email template by using <apex:image url="{!relatedTo.LastModifiedBy.smallphotourl} /> . But when I send email then in place of Image I see  'X' in vf Template.

Then I took help of below link :
https://help.salesforce.com/HTViewSolution?id=000003730&language=en_US

So according to this link it is not possible. But is it possible to show that images with a programatically approach ?
 
Best Answer chosen by Shubh2910
JeffreyStevensJeffreyStevens
User userRec {get;set;}

....

userRec = new User();
userRec = [SELECT id,FullPhotoURL FROM USER LIMIT 1];

Then from the page....
<apex:image value="{!userRec.FullPhotoUrl}" height="100" width="80" />


I do that - in a custom HTML email template.
 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi

This is possible if the images are stored in documents and with "Externally Available Image" checked.
<apex:image id="theImage" value="https://c.<instance>.content.force.com/servlet/servlet.ImageServer?id=<document_id>&oid=<organization_id>" width="200" height="200"/>

Please refer below link which has steps how to do it.

http://salesforce.stackexchange.com/questions/114778/incorporating-image-in-email-template/121601#121601 

http://salesforce.stackexchange.com/questions/4641/is-is-possible-to-display-an-image-or-icon-in-a-email-using-a-visualforce-templa

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya


 
Shubh2910Shubh2910
Hi Sandhya,

Thanks for your response.

But my problem is not one or two image which I can upload in documents. I want to show Profile picture of salesforce users in email template and these pictures are already existing in Salesforce but not in Documents and there may be any number of users present in my salesforce org. So I also cannot download all pictures and then store those pictures in Documents.
 
JeffreyStevensJeffreyStevens
User userRec {get;set;}

....

userRec = new User();
userRec = [SELECT id,FullPhotoURL FROM USER LIMIT 1];

Then from the page....
<apex:image value="{!userRec.FullPhotoUrl}" height="100" width="80" />


I do that - in a custom HTML email template.
 
This was selected as the best answer
Jatin Sethi 26Jatin Sethi 26
HI @Shubh2910

Did you got any workaround for this query?