Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9256891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:02+00:00 2026-06-18T12:05:02+00:00

The requirement is to upload attachments to a server. However, we only want to

  • 0

The requirement is to upload attachments to a server. However, we only want to upload those appears in the “Message” line (see pic below) of outlook, nothing else in the email body.

Since Outlook itself knows which attachment should be show in the line, there must be information that it uses to distinguish them internally.

So, how can I do that within my VBA program? I have tried to use MailItem.Attachments but all attachments are there and I cannot find any property of them can be used to distinguish.

UPDATE
The original title “Distinguish embadded attachments with Outlook VBA” is a bit misleading. So I have changed the title.

Outlook Screenshot:
Outlook Screenshot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:05:05+00:00Added an answer on June 18, 2026 at 12:05 pm

    As I can test so far, an embedded attachment always have a MIME content ID, regardless whether it appears in the mail body. So the solution is to check whether it has a content ID.

    Here is an example code that counts the visible attachments:

    Sub ShowVisibleAttachmentCount()
        Const PR_ATTACH_CONTENT_ID As String = "http://schemas.microsoft.com/mapi/proptag/0x3712001F"
        Const PR_ATTACHMENT_HIDDEN As String = "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
    
        Dim m As MailItem
        Dim a As Attachment
        Dim pa As PropertyAccessor
        Dim c As Integer
        Dim cid as String
    
        Dim body As String
    
        c = 0
    
        Set m = Application.ActiveInspector.CurrentItem
        body = m.HTMLBody
    
        For Each a In m.Attachments
            Set pa = a.PropertyAccessor
            cid = pa.GetProperty(PR_ATTACH_CONTENT_ID)
    
            If Len(cid) > 0 Then
                If InStr(body, cid) Then
                Else
                    'In case that PR_ATTACHMENT_HIDDEN does not exists, 
                    'an error will occur. We simply ignore this error and
                    'treat it as false.
                    On Error Resume Next
                    If Not pa.GetProperty(PR_ATTACHMENT_HIDDEN) Then
                        c = c + 1
                    End If
                    On Error GoTo 0
                End If
            Else
                c = c + 1
            End If
        Next a
        MsgBox c
    End Sub
    

    When I run through all my outlook emails it gives the same number of attachments in the line.

    UPDATE

    Thanks to Dmitry Streblechenko’s information, I tested Outlook with email generated by Java Email library. The result shows that when an email attachment contains an CID but not appear in the email body, it will appear in the attachments line.

    UPDATE

    It looks there are still some cases that this is not good enough.
    I have generated the following MIME email body:

    Message-ID: <1044564324.2.1360638429705.JavaMail.joe@xxxx>
    Subject: Test
    MIME-Version: 1.0
    Content-Type: multipart/alternative; 
        boundary="----=_Part_0_1327112367.1360638429515"
    Return-Path: xxxx@xxxx.xxx
    X-OriginalArrivalTime: 12 Feb 2013 03:07:16.0096 (UTC) FILETIME=[0FC1B000:01CE08CE]
    
    ------=_Part_0_1327112367.1360638429515
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    
    TTT
    ------=_Part_0_1327112367.1360638429515
    Content-Type: multipart/related; 
        boundary="----=_Part_1_1747887937.1360638429520"
    
    ------=_Part_1_1747887937.1360638429520
    Content-Type: text/html; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable
    
    <html><head><meta http-equiv=3D'content-type' content=3D'text/html; charset=
    =3DUTF-8'></head><title>TTT</title><body><img src=3D"cid:test1.png" alt=3D'=
    =E6=81=AD=E8=B4=BA=E6=96=B0=E7=A6=A7' /><p>txt</p></body></html>
    ------=_Part_1_1747887937.1360638429520
    Content-Type: image/png
    Content-Transfer-Encoding: base64
    Content-ID: <test.png>
    
    iVBORw0KGgoAAAANSUhEUgAAAIIAAAAmCAYAAAAIjkMFAAABHUlEQVR42u3Z0Q7CIAyFYd//pafx
    ckFoS9ELvz8aE9mQrIfTFh8PAAAAAPgp1+t1vT9i32fm6FzP6JrKb3aulRAGARm9Z9dUAhWZY7Wm
    7Hr+IvhdD+s+PhLCLNBZQZ12HI7QlBqyQohctxM8bvAFIcx2eEYIo/vuY5WAi3BzWlhZ+if7zs7T
    UWtE10Asgd3bUSxWHvrMobJOtXITQkjk5Z3gdaWaqBBWouYIhdy+E+TsPNHU0CUEbjDJ49GxE0KI
    nBNUheAcYbPVy9QNmRaxUvVHd7Idf0gU2QDOduVqnkinoEb4QY1Q3V2RNrMqpB0h6BqKh0gZIWT/
    AzjVycwcjSMcPI3buSebZiptaLbIBQAAAAAAAAAAAAAAAP6OJyO5jJ4bZa/gAAAAAElFTkSuQmCC
    
    ------=_Part_1_1747887937.1360638429520--
    
    ------=_Part_0_1327112367.1360638429515--
    

    Notice that I have changed the referencing image content id in the body, and the actual image have a wrong content ID (so it is not referenced). However the image is not in the main part of the email (it is in a branch of an alternative part). That makes it invisible in outlook.

    So to detect we have to make sure the attachment appears in the main MIME part… Looking for ways to do so.

    UPDATE

    Further digging I reaches this link and I added one more test – the PR_ATTACHMENT_HIDDEN property.

    Also it is worth to say that outlook 2010 itself is not consistent. I have observed that sometimes the email list shows the attachment icon to indicate existence of attachments but there are nothing appear when opening it in an inspector.

    References:

    Sending Outlook Email with embedded image using VBS

    MSDN – Attachment Properties

    Forum – Identifying inline attachments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Friends I want to upload a image but according to requirement when click
I have requirement to upload photos to server using php. Usually, the user selects
My requirement is : I want to upload the sqlite table records to MS
I have a requirement to upload image on server in 2 size, normal and
In a web project using jsp, I have following requirement Upload a file (say
According to current requirement,user will upload files with large size,which he may like to
Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
Requirement : Should update MySQL database with that of MS Sql Server updates which
Requirement is like: I want to take input values from user in frame but
I have a requirement where I have to upload a file to db. File

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.