This project is read-only.

How to get the Embedded Image in the Body object of Message

Jun 23, 2012 at 12:57 PM

I am reading the mail from the server in that mail the image is pasted in the body so if i read the mail using RerieveMessageObject check the HtmlBody properities in the message object i just get the image source tag with some message id i am not able to get the full image as html in the body. The image related some propeties is there in the Embedded objects using the embedded object in the mimepart i am able to save that image to some location but i don't want to save the image in some location but i need to show the image in the body of web browser or TxtTextControl  can any one help relating to this how to get the embedded image in the body or show the image the Web Browser

Aug 16, 2013 at 10:25 PM
If you have managed to get the embedded image what you could do is implement an HttpHandler - an HttpContext is passed into the Handler and that handler includes a stream which basically is the browser.
public void ProcessRequest(HttpContext context)
{
    .
    .
    .

    try
    {
    .
    .
    .                   
        imageBytes = GoogleConsumer.GetImage(contact.PictureUrl, refreshed.AccessToken);
        if (imageBytes != null)
        {
            imageStream = new MemoryStream(imageBytes);
            image = System.Drawing.Image.FromStream(imageStream);

            context.Response.ContentType = "image/jpeg";
            image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        }                                                      // end if (authCookie != null)
    }
    catch (System.Exception ex)
    {
        throw ex;
    }
    finally
    {

    }
}
The imageStream is the image as a byte array - this is converted into a stream before this in turn is loaded into an image and then the image is saved.

I've not tried this with mailsystem - the above comes from a project which retrieves images from the Google Contact API - and expects a Url - but you should be able to adapt the code.