throws MessagingException, TransformerException, IOException
{
DataHandler handler;
if (payload instanceof String)
{
handler = new DataHandler(new ByteArrayDataSource((String) payload, contentType));
}
else if (payload instanceof byte[])
{
handler = new DataHandler(new ByteArrayDataSource((byte[])payload, contentType));
}
else if (payload instanceof Serializable)
{
handler = new DataHandler(new ByteArrayDataSource(
(byte[])new SerializableToByteArray().transform(payload), contentType));
}
else
{
throw new IllegalArgumentException();