Image object (as a mail attachment) filepath

1

I am creating an add in for outlook 2007, that embeds smileys to the body of an email.

And the method i am using is as follows:

if (!string.IsNullOrEmpty(mail.HTMLBody) && mail.HTMLBody.ToLower().Contains("</body>"))
            {
                int mailBodyLength;
                if (mail.Body == null)
                {
                    mailBodyLength = 0;
                }
                else
                {
                    mailBodyLength = mail.Body.Length;
                }
                //Get Image + Link
                Image imagePath = image;
                object linkAddress = "http://www.pentavida.cl";

                //CONTENT-ID
                const string SchemaPR_ATTACH_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
                string contentID = Guid.NewGuid().ToString();

                //Attach image               
                mail.Attachments.Add(imagePath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, mailBodyLength, Type.Missing);
                mail.Attachments[mail.Attachments.Count].PropertyAccessor.SetProperties(SchemaPR_ATTACH_CONTENT_ID, contentID);

                //Create and add banner
                string banner = string.Format(@"<br/><a href=""{0}"" ><img src=""cid:{1}"" ></a></body>", linkAddress, contentID);
                mail.HTMLBody = mail.HTMLBody.Replace("</body>", banner);

                mail.Save();
            }

In this line : mail.Attachments.Add(imagePath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, mailBodyLength, Type.Missing);

I am adding an image object (imagePath) but its throwing an exception, it worked when i put a full path of an image in the method, now i am passing through an image that was got from my resources folder. I am assuming that the method is failing because it needs a path of the image and not the Image object. How do i get the Image path name from this Image object to pass into this method?

I have an image that i got from my resources folder, i need the path of that image. How do i get that path?

Image imagePath = image;

I need the image path because i am adding the image to a new mail in outlook.

But when i pass through the Image object it throws an exception of:

 Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

But passing a string works fine.

thanks in advance.

c#
image
asked on Stack Overflow Feb 4, 2012 by johnnie • edited Feb 4, 2012 by johnnie

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0