
MAPI.HrGetOneProp(IProperty, uiPropertyTag, pPropValue)

Marshal.QueryInterface(IUnk, guidMAPIAttach, IProperty) If (res MAPI.S_OK) Then Dim guidMAPIAttach As Guid = New Guid(MAPI.IID_IAttachment) IUnk = Marshal.GetIUnknownForObject(oMAPIObject)ĭim guidMAPIProp As Guid = New Guid(MAPI.IID_IMAPIProp)ĭim res = Marshal.QueryInterface(IUnk, guidMAPIProp, IProperty)
OUTLOOK ATTACHMENT SIZE LIMIT 2007 CODE
What kind of interface will be implemented in Outlook 2010 is unclear so far, that is why I am leaving the code as is, with 2 QueryInterface calls: Private Function GetMAPIProp( _īyVal uiPropertyTag As UInteger) As Long If (oMAPIObject Is Nothing) Then Return 0 The point is that Outlook 2003, 2007 and Outlook 2010 return only the IMAPIProp interface, while Outlook 2000 and Outlook XP return the IAttach interface only. Pay attention here to the two calls of QueryInterface. Initialize Extended MAPI, query the right interface, get the SPropValue structure and receive the wanted value. In the GetMAPIProp method, you dig for the needed PR_ATTACH_SIZE property. Empty For i As Integer = 1 To attachments.Countĭim attach As Outlook.Attachment = attachments.Item(i) If attachments.Count > 0 Then Dim Output As String = String. The DoGetAttachmentSize method is quite simple, the code below processes the Attachments collection: Private Sub DoGetAttachmentSize( ByRef mail As Outlook._MailItem)ĭim attachments As Outlook.Attachments = mail.Attachments It is that second method that we are going to scrutinize today. The first method is as follows: you store each attachment in a temporary file, then query the file size, and after that delete that temporary file. The other, and probably a smarter way, is getting the attachment size via the PR_ATTACH_SIZE Extended MAPI property. There exist at least two methods of getting the attachment size in older Outlook versions, that is in Outlook 2003, XP and 2000.

The new Size property of the Attachment object was introduced in the Outlook 2007 Object Model.
