Hello Inna,
First, try attachment["body"].ToString() and if it returns a string object... if not, cast is to byte[]: (byte[])attachment["body"] . Here are some helpful methods for conversion from byte[] to string and viceversa:
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
static string GetString(byte[] bytes)
{
char[] chars = new char[bytes.Length / sizeof(char)];
System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
return new string(chars);
}
After you get the desired string you can simply create a new Email entity and set email["body"] attribute to the output string from the attachment.
Cornel Croitoriu - Senior Software Developer
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

