Adding .msg file as attachment gives size of 0

Add-in Express™ Support Service
That's what is more important than anything else

Adding .msg file as attachment gives size of 0
Mark Wijnbergen

Posts: 26
Joined: 2019-03-18

When adding any type of file as attachment to an email, the
abstract method of the
abstract class is called.
The attachment that has been added is received as an
argument in this method.
Whenever this function is called, it is possible to read all information of the attachment via

public override void ProcessAttachmentAdd(object attachment)
    var att = attachment as Outlook.Attachment;
    var size = att.Size;
    var name = att.DisplayName;

I seem to have an issue with getting the size of .msg file that are added as an attachment:
The file size of .msg attachments are returning 0, whereas files with a different kind of attachment (tested on .docx, .md, .png and .xlsx files) give the correct size of the file.

Is this a bug within Office/Add in Express or is this deliberately done?

Thanks in advance and best wishes,

Posted 02 Jan, 2020 09:27:26 Top
Andrei Smolin

Add-in Express team

Posts: 17243
Joined: 2006-05-11
Hello Mark,

The Outlook object model and its behavior is what you get from Microsoft. Since it returns Attachment.Size=0 for such an attachment, you can't change this. Still, I would consider intercepting clicking the built-in Ribbon button IdMso="BrowseToAttach". When it is clicked, you cancel the click, and call ADXAddinModule.SendMEssage passing it a unique message (=an integer >1024). When the message is received by the hidden window that Add-in Express creates for your add-in, the ADXAddinModule.OnSendMessage event occurs. In the event handler, you check that the message received is your message; if this is it, you use the Windows API to show the FileOpen dialog to the user. When the user selects a file and clicks OK, you get the size of the file for your needs and attach the file to the email.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Jan, 2020 05:00:04 Top