converting base64 encoded string as an image

Hi All,

I am trying to convert base64 encoded string back to image and sending it as a mail attachment.
but it is not working…the resulting image file seems to be corrupted,unable to open it.

i have passed base64 encoded string as input to pub.string:base64Decode
and then passed the resulting byte array to content of pub.client:smtp service.