Unknown Exception Error while trying to send out a Visualforce Email Template

Today i’ve spent the better part of the day trying to figure out why I cannot send out automated emails based on a Visualforce Email template. When I tried to send out the Email Template from some Scheduled Batch code, I’d recieve the following error message:

System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: Argument Error: Parameter value is null: []

After viewing a few forum posts and doing some of my own experimentation, I’ve found out at least 2 things that can give you this error.

<apex:image> tag

These tags must be replaced with the standard HTML <img> tags. This is pretty straight forward, as most <apex:image> attributes correlate directly to an <img> attribute and don’t need to be touched. The <apex:image> attributes value and styleClass can be replaced with src and class attributes, respectively.


The only tricky attribute is probably the rendered attribute. You could try to map this style and put in a clever VF formula which could evaluate to display:none or display:inline, but that CSS may not be supported by your email client. (Outlook 2007/2010 doesn’t. *sigh* Look here for more info on the differences between email client CSS support.)

A solution that works is to wrap the <img> tag in a <apex:outputPanel> tag and apply the rendered expression to this tag.

<apex:outputLink> tag

This tag also needs to be replaced with the HTML <a> anchor tag. Again, the conversion is fairly straight forward. The tricky attributes are rendered and disabled. Again, I think <apex:outputPanel> tags and some CSS styling can be used to do the same things.


Hopefully this saves someone the grief and hair-pulling I went through.

Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+Email this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>