fair warning: i'm little bit of rookie c#
, outlook, bear me on this.
i've been experimenting emails in outlook quick , dirty addin i'm building, addin requires me send attached files different system.
long story short; in order need convert outlook item's mail attachment byte
array.
what have far (and complete code miles longer this, i'm sure have better things sit , read page , page down of code):
outlook.selection sel = control.context outlook.selection; outlook.mailitem mail = sel[1]; outlook.attachment = mail.attachments[0];
problem is, have no idea how convert a
byte
array.
ps: know there billion answers how convert byte
array mail, none explain how running other way around.
edit 1: rather not have save file.
the second method proposed dmitry (open attachment binary stream) achievable in managed code. uses propertyaccessor interface, available attachment objects in c#. here sample code i've used in own project:
const string pr_attach_data_bin = "http://schemas.microsoft.com/mapi/proptag/0x37010102"; outlook.attachment attachment = mail.attachments[0]; // retrieve attachment byte array var attachmentdata = attachment.propertyaccessor.getproperty(pr_attach_data_bin);
my example code based on how to: modify attachment of outlook email message topic provided ken getz, mcw technologies, llc part of msdn documentation.