I have a function which is responsible for generating an Outlook email with the appropriate information. However, I wish to attach an image from the clipboard. I can already detect if there is an image present in the clipboard and use the picture box control to display it.
IDataObject data = Clipboard.GetDataObject();
Image img = (Image)data.GetData(DataFormats.Bitmap, true);
So with that I'm able to get the image from the clipboard (i didn't show to check whether an image existed or not). With the image object, is it possible to attach it to an Outlook email? From the API it simply shows that Attachment.Add first parameter is Object source.
The error I get when I use the image object directly using:
mailItem.Attachments.Add(img, Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
is System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exceotion from HRESULT: 0x80010105 )RPC_E_SERVERFAULT))
Thank you.