Find your content:

Search form

You are here

How to share an icon between emails?

 
Share

There several tutorials which show how to upload note / attachment for particular object http://salesforceworld.blogspot.ie/2011/06/save-attachment-in-apex.html However, I want to store the same icon as a note / attachment for a selection of custom objects that I end up merging into emails.

Is there anyway I can do this?


Attribution to: dublintech

Possible Suggestion/Solution #1

Attachments must be related to a given object record, they cannot be shared. These are some options to consider...

  1. You could consider if there is a common related record make the attachment to that and reference that in your emails.
  2. Similar to the above, but perhaps create a 'Email Template Settings' custom object, having only one record in it, with custom fields and attachments to items your email template needs.
  3. Upload the icon as a Document into a Folder and reference that from your emails, take a look at this. This blog also provides quite a detailed walk through of how to do this.
  4. You can also consider using a Static Resource to upload your image, this really depends on how often and who needs to change it. As Mohith has pointed out this will not work for Email templates as the Static Resource is not publicly accessible. Given you have been using Attachments, I'm not sure if this is an issue or not. You can generate a PDF from the email to workaround this.

I think your best bet is option 3 personally. If you are packaging your solution, you cannot hard code the ID's. So this bit of code will generate the URL dynamically for you.

Document document = [Select Id, Url From Document Where DeveloperName = 'New'];
String docUrl = document.Url != null ? document.Url : 
      String.format('{0}/servlet/servlet.ImageServer?id={1}&oid={2}', 
         new String[] { URL.getSalesforceBaseUrl().toExternalForm(), 
                        document.Id, 
                        UserInfo.getOrganizationId() });

NOTE: Updated to check with the document has been explicitly given a URL by the end user and uses that instead.


Attribution to: Andrew Fawcett

Possible Suggestion/Solution #2

enter image description here

enter image description here

I have SnapShots from my org on how you can upload a document from Your Local.Just Upload and store the Id generated after you upload from URL in custom label and you can follow the document http://login.salesforce.com/help/doc/en/email_template_images.htm to get the image in your Vf template


Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4644

My Block Status

My Block Content