Tuesday, March 24, 2009

Adding an Anchored Logo to Your HTML Email Template

A friend and fellow Salesforce Geek wanted to know how she could insert a company logo as the header in an HTML email template, such that when the user clicked on the logo, their browser would navigate to her company's website. I tried to describe it in email, but I suspect not very well. I promised her I'd blog about it ... so here we are.


Disclaimer: As with most things in Salesforce, there are a dozen different ways to get from Point A to Point B. This is certainly not the only approach, just the first that popped into mind.

Let's do it by the numbers. First, I created a quick logo image:




Host the Logo Image

Store the logo image in a location where it can be accessed over the internet. For this exercise, I'm going to store the image on the Salesforce servers, under the Documents tab:

1.) Click the Documents Tab.



2.) Click the "Create New Folder" link (we're going to create a new folder to store email images)


3.) In the Document Folder Label field, type "_Images". Click tab and set the other fields to their defaults. Save.


NOTE: The underscore "_" character in front of the word "Images" is intentional. Folders sort in alphabetical order, and this will push your Images folder down to the bottom of the folder list. That's my personal preference, so that my Image folders don't get mixed in with my "real documents" folders.



4.) Now that you're in the "_Images" folder, click "New Document".


5.) Enter the logo name, unique name, description, and browse to the path where the image is located. Because we will be including this image on an external email template, set the "Externally Available Image" checkbox.



Creating the Email HTML Template

Now that the logo image is "hosted" in a public location, create the email HTML Template:

6.) Click Setup -> Email templates. Specify the folder (or create a new one), and click "New Template".


7.) Select the "Custom (without using Letterhead)" option. Click "Next".


8.) Set the "Available for Use" checkbox, give your new email template a name and fill in the description field.


9.) This sample HTML code starts with an anchored logo, then continues with the "form letter" that recipients can read:



<a href="http://forcemonkey.blogspot.com">
<img src="https://na3.salesforce.com/servlet/servlet.ImageServer?id=01550000000Nqqc&oid=00D500000007zyA"/>
</a>
<br>
<br>
Dear {!Contact.FirstName} ,<br>
<br>
Check out our new logo! Interested in the latest tips and tricks? Click the logo in the top left corner, and it will take you to our website!<br>
<br>
Best Regards,<br>
<br>
From the Force Monkey Troop


Let's rewind a little bit, to explain the HTML code:

The anchor tag, which starts with a href="http://.../" creates a link to the target website, referenced in the href arguement. In this case, I used the URL for this blug (http://forcemonkey.blogspot.com). Substitute your own target website after the href arg.

The image that we're wrapping the anchors around is specified in the img src="https://na3.salesforce..." tag. But what is that crazy long string after the "src" arg? That's the location where the image is stored on Salesforce servers.

To get this URL information for the logo you stored, do this (assumes you're on a PC):

1.) Click on the Documents tab

2.) Select your Logo image "document"

3.) Right click on the image. Click "Properties".



Copy the "Address URL" field to your text buffer. Be sure to capture the entire field, by holding the left mouse button down as you click from the left of the "https:" and drag the cursor downward until all characters of the field are highlighted. Press CTRL-C to copy to your text buffer.

4.) Open your email HTML template and press CTRL-V to paste it in the "src" arg of the img HTML tag.

Add the remaining HTML text for your email template, as necessary. Viola!

If the steps here are still just a little confusing, let me know -- I'll post a video blog of the whole process.

Tuesday, March 10, 2009

Support for Salesforce S-Controls To Be Discontinued


SOURCE: All credit to my information source: Sonny Cloward (@sonnycloward), Steve Anderson (@gokubi), David Schach (@dschach) and the Non-Profit Salesforce Salesforce Practioners Google Group.

Salesforce.com plans to discontinue support for S-Controls next year. The following warning announcement is displayed to Salesforce.com Administrators in the App Setup -> Develop -> S-Controls page:

"S-controls have been superseded by Visualforce pages. Salesforce will, sometime after January 2010, remove the ability to create and distribute new s-controls. Existing s-controls will be unaffected. For more information, see How Do Visualforce Pages Compare to S-Controls?."

The “end of life” date on S-Controls is a little vague, I suspect intentionally. Sometime after January 2010 could mean anytime that year, or any time in the following decade.

The announcement is problematic for some Developers. While VisualForce and Apex are great, there are certain governor limits of Apex that prohibit its use in every application. I have a couple S-Controls that I haven’t yet converted over to VF/Apex for this very reason. I have other S-Controls, admittedly, that I haven’t converted over for simply lack of time.

Note that existing S-Controls are unaffected. However, they can't be updated or distributed in packages after this EOL date. Developers must convert these S-Controls over to VisualForce pages. VisualForce allows developers to write javascript and HTML directly into their VisualForce pages, so it should be possible to simply copy / paste existing S-Controls into a VisualForce page. That means this end-of-life shouldn’t be much of an issue to most savvy Salesforce Developers.

On the other hand, I find that a lot of Customers don’t have in-house developer expertise. Their S-Controls are either part of an application they downloaded from the AppExchange, or were developed by a contractor. If you don’t have developers in-house, don’t panic! You’ve got plenty of time to inventory your S-Controls over the next few months. Evaluate these components. Are they crucial to your application? Are they likely to require change / updates? If yes, invest the time now into learning VisualForce (so you can convert them yourself) or contact your certified Salesforce.com partner / contractor / consultant.

Have any questions? Reply below!