none
cid, inline embedded images RRS feed

  • Question

  • Hi,

    I have a requirement to send html email with line embedded images. Have completed and its successfully showing inline images in outlook versions. But same email when I see in Windows live hotmail, its not showing the inline images.

    Please help me how to resolve this issue?

    Thursday, August 4, 2011 7:07 AM

All replies

  • Please let me know if I am not clear.
    Friday, September 9, 2011 5:36 AM
  • How exactly do you the content id on the atatchments? What is the HTML source?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Monday, September 12, 2011 10:05 PM
  • as part of constructing exchange server email. I do add attachement(image) and to keep as embedded image as part of html source I will add the below code to display as embedded image.

    <img src='cid:<imagename>'/> 

    But this style is working fine when I receive email in outlook. But in other party emails(yahoo, hotmail, gmail) the embedded image is not displaying. 

    Please let me know what is the alternative approach to display embedded image in all the emails(outlook, yahoo, hotmail, gmail etc...)

     

    Tuesday, September 13, 2011 4:30 AM
  • What is your code?

    What is the resulting HTML?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Tuesday, September 13, 2011 4:49 AM
  •    createItemRequest.Items.Items = new ItemType[1];
        createItemRequest.Items.Items[0] = message;
        try
        {
        // Send the request to create and send the e-mail item, and get the response.
        CreateItemResponseType createItemResponse = esb.CreateItem(createItemRequest);
        // Determine whether the request was a success.
        if (createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
        {
        //throw new Exception(createItemResponse.ResponseMessages.Items[0].MessageText);
        log.Error(string.Format(@"Exchange server error occured {0}", createItemResponse.ResponseMessages.Items[0].MessageText));
        }
        else
        {
                         if (FileAttachments != null && FileAttachments.Length > 0)
                         {
                             ItemInfoResponseMessageType responseMessage = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
                             ItemIdType itemIDType = AddAttachments(responseMessage.Items.Items[0].ItemId.Id.ToString(), esb);
                             //Send the email.
                             SendItemType sendItemType = new SendItemType();
                             sendItemType.ItemIds = new BaseItemIdType[1];
                             sendItemType.SavedItemFolderId = new TargetFolderIdType();
                             sendItemType.ItemIds[0] = itemIDType;
                             DistinguishedFolderIdType siSentItemsFolder = new DistinguishedFolderIdType();
                             siSentItemsFolder.Id = DistinguishedFolderIdNameType.sentitems;
                             sendItemType.SavedItemFolderId.Item = siSentItemsFolder;
                             sendItemType.SaveItemToFolder = true;
                             SendItemResponseType siSendItemResponse = esb.SendItem(sendItemType);
                         }
        log.Info("Email sent successfully.");
        }
        }
        catch (Exception e)
        {
        log.Error(string.Format(@"Exception occured {0}", e.Message));
        throw;
        }
    The above is for creating itemrequest and attaching images and sending email. As part of html body of message we do add as below.
    <img src='cid:<attachmentimagename>'/> 
    The above code and html embedded image are working fine in outlook email. But not displaying the embedded images in yahoo, gmail etc...
    Tuesday, September 13, 2011 4:56 AM
  • If you are using file name, do nnot use cid: just use <img src=ImageFilename.jpg> 

    If you want cid, you must set the Content-Id MIME header on the attachment (or PR_ATTACH_CONTENT_ID in MAPI speak).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Tuesday, September 13, 2011 5:02 AM
  • If I just use <img src=ImageFilename.jpg> without cid, will the images appear as embedded images in outlook, yahoo, gmail etc... ?
    Tuesday, September 13, 2011 5:29 AM
  • I don't know. Have you tried that?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Tuesday, September 13, 2011 5:43 AM
  • Yes, Initially I have tried this way, but the embedded images were not displayed without specifying cid 
    Tuesday, September 13, 2011 5:46 AM
  • If I remember correctly, Outlook will display attachments like that.

    have you tried to set the Content-Id MIME header on the attachment?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Tuesday, September 13, 2011 5:48 AM