Send an email template with a GIF attachment

Today we will show you how to send an email template with a GIF return label attached once a shipment is created from a Case.

Before you can write any code you need to set up three things;

  1. Email template
  2. Notification checkbox
  3. Create a new lookup relationship from the UPS Shipment to the Case object

First thing you need to do is create an email template. This you can do by going into Setup > Administer > Communication Templates > Email Templates

 

 

Create a new ‘custom’ template and name it “UPS Shipment

 

 

Then add your html code and subject line. At this point you can add your merge fields as well. An example merge field that could be used is, if you have a list of brands that are related to the case. {!zkups__UPSShipment__c.Case_Brand__c}

 

Secondly you need to create a new checkbox on the Case object, let’s call it “Zenkraft Notification”, it should then create a field called Zenkraft_Notification__c. This basically ensures the email is only sent once.

 

Thirdly, go to Setup > Create > Object > UPS Shipment and create a new lookup relationship to the Case object. For our example the lookup relationship is New_Case__c.

 

Finally we get to write some code, we’ve set this up as a scheduled job that runs once a day to send emails out:

 

  1. Find the template you created earlier
  2. Select UPS Shipments that you want to create emails for:
  3. If you want to add a brand specific logo to each email then you need to use this code to get the name of the image from your SalesForce Documents folder. This is the code you need to use.
  4. Finally this is the code you should use to bring it all together and send your emails out, and to update the Case object checkbox to true.

If you have any questions we would be glad to help.

You may also like...