Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Regarding a VisualForce email template, I know it is possible to setWhatId(), setSubject() and range of other things in Messaging.SingleEmailMessage. But I just want to set my own parameter.

Let me expand on what I mean by my own parameter. I want to be able to use a parameter in a URL I use in img tag.

<img id="toplogo" src="{!$MyParameter}" height="20"/>

I am merging a custom object into the email. So I could always add a parameter to this custom object and merge that way. But is there anyway I can do it without going near my custom object?

share|improve this question
    
What do you mean by wanting to set your own parameter, can you expand on your use case a bit? Do you mean the content of the mail, for that you can use setHtmlBody and setPlainTextBody. –  Phil Hawthorn Jan 17 '13 at 14:22
    
@Phil Hawton I have updated question. –  dublintech Jan 17 '13 at 14:40
    
so are you just trying to make this logo dynamic within your email template? Is there any logic to determine it? –  Phil Hawthorn Jan 17 '13 at 14:54
1  
Have you tried Custom Label or (hierarchical) Custom Setting (like I've said in salesforce.stackexchange.com/a/7352/799)? –  eyescream Jan 17 '13 at 14:58
    
^ just what I was about to suggest –  Phil Hawthorn Jan 17 '13 at 15:11
add comment

1 Answer

up vote 1 down vote accepted

I don't totally understand what you are trying to do, but if you are trying to add a querystring parameter, that's pretty easy...

<img id="toplogo" src="http://myurl.com/image.png?myparam={!$myParameter}" height="20"/>

Just make sure that your parameter is URL encoded. If you are leveraging Visualforce Components in your Visualforce Email template, you could do that in your controller like so...

public class MyEmailController {
  public String getMyParameter() {
    EncodingUtil.urlEncode('parameter that needs encoding');
  }
}

And the component...

<apex:component controller="MyEmailController" access="global">
  <img id="toplogo" src="http://myurl.com/image.png?myparam={!$myParameter}" height="20"/>
</apex:component>

Here are the docs that might help

share|improve this answer
    
this was a good pointer to get me going. I have another question but will take that in separate thread. –  dublintech Jan 18 '13 at 12:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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