Detaching embedded Images from Outlook 2003 Messages

W

Wassim

Hello All

Is there a clean way to detach embedded images, or pictures, from
MS-Outlook 2003 messages via VBA?

What I want to do is extract all the images embedded in a message and
save them to a special folder.

I am doing this via code, so that I don't need to sift through the
1000s of messages that we get.

Thanks

Wassim
 
E

Eric Legault [MVP - Outlook]

The only way to access embedded images is with Extended MAPI (C++/Delphi).
 
G

Grég

Hi,

You can try the code below, it works to extract most attachements (of
current opened message).

Regards.
--->
Sub Get_Attachment()
Dim attach As Attachment
Dim myitem As Outlook.MailItem
Dim myOlapp As Object
Dim attachs As Object

On Error Resume Next

Set myOlapp = Application
Set myitem = myOlapp.ActiveInspector.CurrentItem
Set attachs = myitem.Attachments

For Each attach In attachs
attach.SaveAsFile "C:\temp\OL-attach\" & attach.DisplayName
Next
End Sub
<----

This code is mostly from MS KB. Its purpose was to save smime.p7m file that
you can't acces as a "standard" attachement.
 
E

Eric Legault [MVP - Outlook]

Thanks Greg. Your code is of course correct for dealing with most attachments, however Wassim's issue is specifically with embedded images (of type olOle). These Attachment objects do not have a valid file handle like regular attachments, and cannot be saved as a file using Outlook VBA.
 
W

Wassim

Thank You Eric

I am way not familiar with C++ or Delphi, has anyone done any work
that I can take as a starting point and see how it works?

Also, if this is the only way to deal with embedded images, is there a
way to detect them in a message via VBA?

Maybe what I can do is detect the messages that has embedded images,
and then isolate them into a folder and deal with these messages
manually.

Thanks

Wassim
 
E

Eric Legault [MVP - Outlook]

Sorry, I don't know much if anything about C++/Delphi, nor can I point you to any resources.

Embedded images are still valid Attachment objects, and Attachment.Type = olOle. They also differ from normal attachments in that the FileName and PathName properties return errors when you try to access their values (PathName error number is -903856123, FileName error number is -2082455547).
 
N

nycboy

Hi Wassim and Eric,

I am curious about the messages with embedded images.
Are they only for Outlook 2003, or other versions too?
Can you send me a sample message of this kind? I would
like to play with it.

Thanks!

-david
[email protected]


---- Original message ----

Re: Detaching embedded Images from Outlook 2003 Messages
From: Wassim
Date Posted: 6/16/2004 4:44:00 PM



Thank You Eric

I am way not familiar with C++ or Delphi, has anyone done any work
that I can take as a starting point and see how it works?

Also, if this is the only way to deal with embedded images, is there a
way to detect them in a message via VBA?

Maybe what I can do is detect the messages that has embedded images,
and then isolate them into a folder and deal with these messages
manually.

Thanks

Wassim


Re: Detaching embedded Images from Outlook 2003 Messages
From: Eric Legault [MVP - Outlook]
Date Posted: 6/16/2004 8:48:00 PM



Sorry, I don't know much if anything about C++/Delphi, nor can I point
you to any resources.

Embedded images are still valid Attachment objects, and Attachment.Type
= olOle. They also differ from normal attachments in that the FileName
and PathName properties return errors when you try to access their
values (PathName error number is -903856123, FileName error number is
-2082455547).

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
E

Eric Legault [MVP - Outlook]

All versions of Outlook support embedded images in HTML/Rich Text message
bodies. However, the issue we are referring to occurs with images embedded
in Rich Text messages that cause the Attachment object to behave
differently.

A simple way to do this is to copy an image from a Word document and paste
it into the body of the message.
 
G

Grég

Eric,

I think it is "embedded" which was for me quite confusing. In fact, the
code works also for image inserted in html as:
<img width=200 height=160 id="_x0000_i1025"
src="cid:[email protected]">
This type of images seems embedded as they appear in the text and not in the
attachement section. But I can understand this is not the "embedded" type
you are discussing as this type of image is of type olAttachements.

--
Grég



Eric Legault said:
Thanks Greg. Your code is of course correct for dealing with most
attachments, however Wassim's issue is specifically with embedded images (of
type olOle). These Attachment objects do not have a valid file handle like
regular attachments, and cannot be saved as a file using Outlook VBA.
 
Top