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
GopalKandulaGopalKandula 

Creating a dynamic header to email template depending on the country code.

Hi ,

 

I am very new to this. I need a solution and ideas regarding this issue. I will brief out clearly(I believe). I had an existing email templetae. I have got nothing to do with it but to change the header logo.

 

For this I got intial suggestion is To create a visualforce page and a controller to show the header dynamically on the email template depending on the user country code.

 

I have no way to Go. As of now my thought process is create let us say 4 different logos in static resources and create a visua force component for image with a condition of if country code is such then the image orheader should be such. And then call this vf component in  the email template.

 

I need suggestions and solution quickly please.

Best Answer chosen by Admin (Salesforce Developers) 
liron169liron169

I don't see why you need visualforce page?
it engouth to create component + class for the component, and use the component in the template.

 

Assuming the country is value you added in the user object, then:

1.Add all images to static resources, each with name of the relevant country.

2.In the class write somthing like:

String contryLogoURL;

User user=[select id, country from User Where id = :UserInfo.GetUserID()];
contryLogoURL= '/resource/' + user.country;

3.In the component:
<apex:image url="{!contryLogoURL}"/>

All Answers

liron169liron169

I don't see why you need visualforce page?
it engouth to create component + class for the component, and use the component in the template.

 

Assuming the country is value you added in the user object, then:

1.Add all images to static resources, each with name of the relevant country.

2.In the class write somthing like:

String contryLogoURL;

User user=[select id, country from User Where id = :UserInfo.GetUserID()];
contryLogoURL= '/resource/' + user.country;

3.In the component:
<apex:image url="{!contryLogoURL}"/>

This was selected as the best answer
GopalKandulaGopalKandula
Thank You very much.

But can you Please give it in a clear way please, because I am new to coding.

Thanks
liron169liron169

What you define as clear way? I cannot write for you the whole code.

Perhaps, you should first search in google for some code example of email template using visual component.

Can see this for example:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_templates_with_apex.htm

GopalKandulaGopalKandula
Thank you liron169..
I mean in a clear way is the syntax for the class.. i mean the query Please