Following is the code which sends single embedded image very fine from Outlook using c#

public void sendEMailThroughOUTLOOK()
    {
        try
        {
           Outlook.Application oApp = new Outlook.Application();

            Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

            string imageCid = "image001.jpg@123";
            oMsg.HTMLBody = String.Format("<body><img src=\"cid:{0}\"></body>", imageCid);
            Attachment attachment1 = oMsg.Attachments.Add(@"E:\wallpapers\WRLDMAP.jpg", OlAttachmentType.olEmbeddeditem, null, "img");
            attachment1.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);

                           //Add an attachment.
            String sDisplayName = "MyAttachment";
            int iPosition = (int)oMsg.HTMLBody.Length + 1;
            int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
            //now attached the file

            Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\\SampleFile.txt", iAttachType, iPosition, sDisplayName);

            //Subject line
            oMsg.Subject = "Your Subject will go here.";
            // Add a recipient.
            Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
            Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("abc8@in.com");
            oRecip.Resolve();

            oMsg.Send();
            oRecip = null;
            oRecips = null;
            oMsg = null;
            oApp = null;
        }
        catch (System.Exception ex)
        {   }
    }

I dont know how to send multiple embedded images. What modifications are required in the above code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.