Outlook images not seen in to Richtext box

Posted by: gaurang on 7 August 2017, 7:52 am EST

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    I used richtextbox in email body. If I received email from gmail, yahoo or rediffmail etc. then image shows into c1richtextbox but If I try to send image by outlook that time it does not seen. It show me blank space exact size of image.

    Example for.....

    I create a email into outlook containing images which copy from Paint and pest it into email body.

    This type of email when I received in my application it show me blank space instead of images. The same email if I send it to gmail or yahoo and forward it to my application all images seen good.

    I do not know how it is done.

    Please reply me.

    Gaurang.

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    Maybe outlook uses a strange uri format for the images that rtb does not understand. Take a look at the emails in raw mode.

    Bruno

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    Thanks for your reply.

    I have check the image tag It look like this

    Get Email From Outlook

    Get Email From Gmail

    https://mail.google.com/mail/? ui=2&ik=4a6afc472b&view=att&th=12f8c8089183e34f&attid=0.1&disp=emb& zw" width="180">

    (above both are same email)

    Get Email From Yahoo (different email where I can see images)

    I try to send image email from out look to gamil as well as my web application then into gamil all images can seen but in my web application it does not seen.

    Then I try to forward the gmail email to my web application and outlook. Now both place my web application and outlook images not seen. Just only blank spaces of image size.

    Now what should I do.

    Please reply me

    Thanks,

    Gaurang

  • Posted 7 August 2017, 7:52 am EST

    Displaying emails from gmail and yahoo mail works because the uris are from the internet. Outlook on the other hands uses cid: uris to show images embedded in the email itself. You need to extract or load those images and patch up the rtb document so that uris point to the correct location.

    Bruno

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    Thanks for your reply.

    But how to extract pictures from the image tag

    or from outlook server.

    Please reply me.

    Thanks,

    Gaurang

  • Posted 7 August 2017, 7:52 am EST

    Hi Gaurang,

    You need to intercept the HTML import. For example:

    richTB.HtmlFilter.ConvertingHtmlNode += OnConvertingHtmlNode;

    Please take a look to the sample RichTextBoxSamples2010, DemoRichTextBox.xaml.cs.

    Hope this helps!

    Regards

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    Thanks for your reply.

    My problem is that when I received email from Outlook with embedded image that time it does not seen. So I think first I should download the image and then using your above help I need to replace src so it will display.

    But I do not have any idea to download image from the image tag when I received this type of embedded image into email body.

    Please tell me if you have any idea or link so I can solve my problem.

    Thanks,

    Gaurang

  • Posted 7 August 2017, 7:52 am EST

    Is it a stream?

    You can create an image from a stream in Silverlight, in the following way:

    blogs.silverlight.net/.../silverlight-tip-of-the-day-92-how-to-load-images-from-a-stream.aspx

    Obviously, the image format should be supported by the Silverlight framework too. If not, you need to convert it somehow in the server or create your custom Image Decoder. We provide one for GIF Images in C1.Silverlight.Imaging.

    Regards

  • Posted 7 August 2017, 7:52 am EST

    Hi,

    Thanks for your reply.

    techhelp.santovec.us/decode.htm

    www.outlookcode.com/.../htmlimg.htm Using this link also helpful for me to understand MIME and outlook embedded image.

    Now I can download embedded images to Server side from MIME (I used Chilkat.dll for email).

    Below is sample code for downloading image and it is working.

    Chilkat.Mime mime = new Chilkat.Mime();

    mime.UnlockComponent("Anything for 30-day trial.");

    mime.LoadMime(email.GetMime());

    for (int x = 0; x < mime.NumParts; x++)

    {

    if (mime.GetPart(x) != null)

    {

    if (email.GetRelatedContentType(x) != null)

    {

    string[] str = email.GetRelatedContentType(x).ToString().Split('/');

    if (str.Length > 1)

    { //mime.GetPart(x).SaveBody(AppDomain.CurrentDomain.BaseDirectory.ToString() + "ClientBin\img\" + email.GetRelatedFilename(x) + "." + str[1]); //output : F:\XYZ\Com.Server.Web\ClientBin\img\image001.gif

    string path = System.Web.HttpContext.Current.Server.MapPath("~/img");

    mime.GetPart(x).SaveBody(path + email.GetRelatedFilename(x) + "." + str[1]);

    }}}}

    I tried to get image path these way (I used ComponentOne C1RichtextBox)

    1) string hostName = Application.Current.Host.Source.Host;

    2) string serverPath = AppDomain.CurrentDomain.BaseDirectory;

    3) string url = App.Current.Host.Source.ToString

    Replace old path to new path this way.

    void OnConvertingHtmlNode(object sender, C1.Silverlight.RichTextBox.Documents.ConvertingHtmlNodeEventArgs e)

    {

    var element = e.HtmlNode as C1.Silverlight.RichTextBox.Documents.C1HtmlElement;

    if (element != null && element.Name == "img")

    {

    string src;

    if (element.Attributes.TryGetValue("src", out src) && src.StartsWith("cid:"))

    {

    src = src.Remove(0, 4);

    string[] temp = src.Split('@');

    string path = System.IO.Path.GetDirectoryName(App.Current.Host.Source.ToString().Remove(App.Current.Host.Source.ToString().Length - 17)).Replace("\", "//") + "/Images/";

    element.Attributes["src"] = path + App.CurrentUser.UserId.ToString() + temp[0];

    } } }

    Thanks,

    Gaurang

  • Posted 7 August 2017, 7:52 am EST

    Great. Thanks for sharing the solution.

    BTW, I almost use Chilkat component a few years ago, while trying to build an email client. Then I dismissed the project. Is it good?

    Regards

  • Posted 28 July 2022, 5:08 pm EST

    On the File tab, choose Options > Trust Center.

    Under Microsoft Outlook Trust Center, click Trust Center Settings.

    Clear the Don’t download pictures automatically in HTML e-mail messages or RSS items check box.

    Regards,

    Peter

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels