Type of attachment

Å

Åsa Holmgren

The Attachments collection of a HTML MailItem contains both attachments
added by the user (Insert-attachment) AND for example gifs displayed in the
HTMLBody. If I select "File-Save attached files..." only the first type is
listed so Outlook seems to be able to see the difference, but how can I?

I would like something like this:

For each oAtt In oMsg.Attachments
If oAtt.[RealAttachment] = True Then
sAttachments = sAttachments & oAtt.DisplayName
End If
Next oAtt
 
C

Chris Fannin

The "real/user" attachments will have a Type value of 1 (olByValue). The
images within the body have an attachment Type value of 5 (olEmbeddedItem).
Links/shortcuts to a network location have a type value of 4
(olByReference).

So, to figure out which ones are attached files, you can do this:

For Each oAtt In oMsg.Attachments
If oAtt.Type = 1 Then
sAttachments = sAttachments & oAtt.DisplayName
End If
Next oAtt

Chris Fannin
Exchange, Outlook & VB Developer
 
Å

Åsa Holmgren

Thank you Chris!

The problem is that all the attachments seems to have Type 1, even the gifs!
Am I missing something here?
 
D

Dmitry Streblechenko

Embbeded images in the HTML messages are stored as regular attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the user
from saving that attachment using File|Save, Outlook adds an extra property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model: either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Å

Åsa Holmgren

Uhh, well, not exactly solved...
I can't find the Hex value for PR_ATTACH_HIDDEN anywhere, could you please
help?
/Asa
 
K

Ken Slovak - [MVP - Outlook]

There's a sample for that on the Redemption Web site. Here's how you get
that property:
PR_HIDE_ATTACH =
sItem.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}", &H8514) or
PT_BOOLEAN
 
D

Dmitry Streblechenko

That named property is set on the message itself to hide the paperclip icon
in the list view.
To hide a particular attachment (so that it won't show up in File | Save
Attachments), you need to set PR_ATTACHMENT_HIDDEN = 0x7FFE000B.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dennis Brown

Is there any way to access an attached file from the object model? If I want to access the 12th file, how can I do this? I'd like to get the count and list of files, then select one by the index, then have it do the same it would do if I selected it by moving the mouse to the specific file in the Attachments: field, and clicking on it (i.e. if it is a text file, execute Notepad; a .doc extension, execute Word; etc.) Does the object model allow this? What good is it to be able to index the attachments if you can't do something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the user
from saving that attachment using File|Save, Outlook adds an extra property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model: either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dmitry Streblechenko

Yes, you can do all that. Have you looked at the MailItem.Attachments
collection and the Attachment object?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Is there any way to access an attached file from the object model? If I
want to access the 12th file, how can I do this? I'd like to get the count
and list of files, then select one by the index, then have it do the same it
would do if I selected it by moving the mouse to the specific file in the
Attachments: field, and clicking on it (i.e. if it is a text file, execute
Notepad; a .doc extension, execute Word; etc.) Does the object model allow
this? What good is it to be able to index the attachments if you can't do
something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the user
from saving that attachment using File|Save, Outlook adds an extra property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model: either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Michael Bauer

Hi Dennis,

you´d first need to save the attachment to your file system. Then you
can use the Win32 API ShellExecute to open the file with its related
application - if there is an application related to the file´s
extension.

Declaration:

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sample:

ShellExecute 0, "Open", "c:\test.doc", vbNullString, vbNullString, 1

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook


Is there any way to access an attached file from the object model? If I
want to access the 12th file, how can I do this? I'd like to get the
count and list of files, then select one by the index, then have it do
the same it would do if I selected it by moving the mouse to the
specific file in the Attachments: field, and clicking on it (i.e. if it
is a text file, execute Notepad; a .doc extension, execute Word; etc.)
Does the object model allow this? What good is it to be able to index
the attachments if you can't do something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular
attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the
user
from saving that attachment using File|Save, Outlook adds an extra
property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model:
either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dennis Brown

I looked at the Attachments objects, which is where I'm getting the count and Items, but not the MailItems. Would you have an example of code I could use to
1. get the attachment list, and
2. select x attachment from that list?
As I said, I'm a newby at this, and also blind, so the object browser isn't the easiest tool for a screen-reader to use! Not whining, just stating a fact!

--

Thanks,
Dennis
Yes, you can do all that. Have you looked at the MailItem.Attachments
collection and the Attachment object?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Is there any way to access an attached file from the object model? If I
want to access the 12th file, how can I do this? I'd like to get the count
and list of files, then select one by the index, then have it do the same it
would do if I selected it by moving the mouse to the specific file in the
Attachments: field, and clicking on it (i.e. if it is a text file, execute
Notepad; a .doc extension, execute Word; etc.) Does the object model allow
this? What good is it to be able to index the attachments if you can't do
something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the user
from saving that attachment using File|Save, Outlook adds an extra property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model: either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dennis Brown

Is that what Outlook does under-the-hood when a user selects the desired attachment with the mouse?

--

Thanks,
Dennis
Hi Dennis,

you´d first need to save the attachment to your file system. Then you
can use the Win32 API ShellExecute to open the file with its related
application - if there is an application related to the file´s
extension.

Declaration:

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sample:

ShellExecute 0, "Open", "c:\test.doc", vbNullString, vbNullString, 1

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook


Is there any way to access an attached file from the object model? If I
want to access the 12th file, how can I do this? I'd like to get the
count and list of files, then select one by the index, then have it do
the same it would do if I selected it by moving the mouse to the
specific file in the Attachments: field, and clicking on it (i.e. if it
is a text file, execute Notepad; a .doc extension, execute Word; etc.)
Does the object model allow this? What good is it to be able to index
the attachments if you can't do something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular
attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the
user
from saving that attachment using File|Save, Outlook adds an extra
property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model:
either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Michael Bauer

Yes, OL itself can´t be able to know (and open) all possibly incoming
attachment types.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook


Is that what Outlook does under-the-hood when a user selects the desired
attachment with the mouse?

--

Thanks,
Dennis
Hi Dennis,

you´d first need to save the attachment to your file system. Then you
can use the Win32 API ShellExecute to open the file with its related
application - if there is an application related to the file´s
extension.

Declaration:

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sample:

ShellExecute 0, "Open", "c:\test.doc", vbNullString, vbNullString, 1

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook


Is there any way to access an attached file from the object model? If
I
want to access the 12th file, how can I do this? I'd like to get the
count and list of files, then select one by the index, then have it do
the same it would do if I selected it by moving the mouse to the
specific file in the Attachments: field, and clicking on it (i.e. if
it
is a text file, execute Notepad; a .doc extension, execute Word; etc.)
Does the object model allow this? What good is it to be able to index
the attachments if you can't do something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular
attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent
the
user
from saving that attachment using File|Save, Outlook adds an extra
property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model:
either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dmitry Streblechenko

I am not sure what you mean: if you are already accessing the Attachments
collection, it can only come from MailItem.Aattachments property (or other
item, such as ContactItem), so I am not sure what question # 1 means. As for
#2, do you mean select in what sense? As in when you select it in an
Inspector?
You can save an attachment to a file system using Attachment.SaveAsFile, you
can then manipulate it using teh regular Windows API.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

I looked at the Attachments objects, which is where I'm getting the count
and Items, but not the MailItems. Would you have an example of code I could
use to
1. get the attachment list, and
2. select x attachment from that list?
As I said, I'm a newby at this, and also blind, so the object browser isn't
the easiest tool for a screen-reader to use! Not whining, just stating a
fact!

--

Thanks,
Dennis
Yes, you can do all that. Have you looked at the MailItem.Attachments
collection and the Attachment object?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Is there any way to access an attached file from the object model? If I
want to access the 12th file, how can I do this? I'd like to get the count
and list of files, then select one by the index, then have it do the same it
would do if I selected it by moving the mouse to the specific file in the
Attachments: field, and clicking on it (i.e. if it is a text file, execute
Notepad; a .doc extension, execute Word; etc.) Does the object model allow
this? What good is it to be able to index the attachments if you can't do
something with it!
Very, very new at this...can't you tell?!

--

Thanks,
Dennis
Embbeded images in the HTML messages are stored as regular attachments, they
just have an extra property (PR_ATTACH_CONTENT_ID or
PR_ATTACH_CONTENT_LOCATION) set.
HTMLBody refers to these images as <img src=cid:somevalue...> where
"somevalue" is thee value of the attachment content id. To prevent the user
from saving that attachment using File|Save, Outlook adds an extra property
(PR_ATTACH_HIDDEN).
These properties are not accessible though the Outlook Object Model: either
Extended MAPI/CDO 1.21/Redemption are required

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top