code: public static String getCharsetFromContentType(final String type) throws MessagingException
  	{
  		if (!type.isNullOrEmpty())
  		{
  			int start = type.indexOf(EmailConstants.CHARSET_PREFIX);
  			if (start > 0)
  			{
  				start += EmailConstants.CHARSET_PREFIX.length();
  				final int offset = type.indexOf(" ", start);
  				if (offset > 0)
  				{
  					return type.substring(start, offset);
  				}
  				else
  				{
  					return type.substring(start);
  				}
  			}
  		}
  		return null;
  	}
docs: Gets the encoding from the header.
  
  @param type
  The string where the encoding is in.
  
  @return 's the encoding or null if its nothing found.
  
  @throws MessagingException
  is thrown if the underlying implementation does not support modification of
  existing values