开发者

Can I attach an image from the clipboard?

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.


Save the image to disk first.

Add Method (Attachments Collection)

Syntax

objAttachments.Add(Source, [Type], [Position], [DisplayName])

objAttachments Required. An expression that returns an Attachments collection object.

Source Required Variant. The file (represented by the full path and file name) or item that constitutes the attachment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜