Outlook
(1)
AdSaveCreateOverWrite
(1)
AdFailIfNotExists
(1)
IDataSourcePtr
(1)
AdModeReadWrite
(1)
IMessagePtr
(1)
IDataSource
(1)
SaveToFile
(1)

HTML format in eml file

Asked By Varun
28-Oct-09 06:59 AM
CDOEX IMessage interface provides function to create eml file
IMessage->Stream->SaveToFile
If there is a mail which has an embeded image in its body and if i save
create eml file for this mail using IMessage->Stream->SaveToFile then embeded
image will not display in body of eml file. Eml file will show it as
attachment.
Is there any option to show it in mail body when open eml file.

I found we need to convert mail format to html but dont know how.
Please suggest.

How do you refer to the image in the HTML body?

Dmitry Streblechenko replied to Varun
29-Oct-09 03:08 PM
How do you refer to the image in the HTML body?

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

The same way how exchange server refer to.

Varun replied to Dmitry Streblechenko
30-Oct-09 03:13 AM
The same way how exchange server refer to.

For an exchange user, when a mail(which contains embeded image in body)
receive on exchange server, i open this mail using CDOEX IMessage and
IDataSource interfaces and create eml file using IMessage->Stream->SaveToFile.

IMessagePtr pMsg( __uuidof( Message ) );
IDataSourcePtr pDsrc = NULL;

USES_CONVERSION;
HRESULT hr = pMsg->get_DataSource(&pDsrc);
hr = pDsrc->Open(  "mailpath",
NULL,
adModeReadWrite,
adFailIfNotExists,
adOpenSource,
_bstr_t() , _bstr_t() );
pMsg->GetStream()->SaveToFile("c:/emlfilename.eml",adSaveCreateOverWrite);

No, I mean how do you refer to the image in the HTML body?

Dmitry Streblechenko replied to Varun
30-Oct-09 12:33 PM
No, I mean how do you refer to the image in the HTML body? What does <img>
tag look like?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
To know about img tag i read complete mail text
Varun replied to Dmitry Streblechenko
31-Oct-09 06:44 AM
To know about img tag i read complete mail text using
IMessage->Stream->ReadText(mailtext). Here img tag is like

src=3D"cid:image001.jpg@01CA5A42.D2B24400">

There are some other information about this image from mailtext

Content-Type: image/jpeg;
name="image001.jpg"
Content-Transfer-Encoding: base64
Content-ID: <image001.jpg@01CA5A42.D2B24400>
Content-Description: image001.jpg
Content-Location: image001.jpg

I can also get img tag information mail htmlbody

htmlbody = IMessage->HTMLBody

src="cid:image001.jpg@01CA5A42.D2B24400">


Above mail i send without any attachment and insert a picture in its body.
Above mail i send using HTML mail format.

But i send a mail without attachment and insert a picture in body using rich
text mail format, when mail arrives on exchange server i create its eml file
but this eml file does not contains any picture not in body not as attachment.
What to do for that case?
What exactly do you mean by the following?
Dmitry Streblechenko replied to Varun
02-Nov-09 03:27 PM
What exactly do you mean by the following? You msu tinclude an atatchment if
yo urefer to it in the HTML body.


But i send a mail without attachment and insert a picture in body using rich
text mail format, when mail arrives on exchange server i create its eml file
but this eml file does not contains any picture not in body not as
attachment.
What to do for that case?

-->

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
Here my question was when i send a mail with image in body using htmlformat, i
ashish replied to Dmitry Streblechenko
02-Nov-09 04:57 PM
Here my question was when i send a mail with image in body using html
format, i receive mail on exchange server and create its eml file using
CDOEX IMessage interface but eml file does not show image in body. It shows
image as attachment. You asked me to show IMG tag for image in htmlbody. I
found below img tag, and i am  expecting it is possible to show embeded image
in body of eml file when create eml file.
src=3D"cid:image001.jpg@01CA5A42.D2B24400">


Here i send a mail with image in body using rich text format and create eml
file for this mail then i do not find that image in eml file. Image does not
exist in eml file body or attachment. What to do to get image in eml file?
If we create eml file using IMessage interface then embeded image displaysas
varun replied to Dmitry Streblechenko
04-Nov-09 03:26 PM
If we create eml file using IMessage interface then embeded image displays
as attachment in eml file. please confirm IMessage provides no help to show
embeded image in body of eml when create eml file.

When we send mail using rich text format and we create eml file for this
mail using IMessage then embeded image does not save in eml file. Is there
any way to extract embeded image from mail using IMessage and save in eml
file.
Sorry, but I still do not understand what you mean.
Dmitry Streblechenko replied to ashish
04-Nov-09 03:42 PM
Sorry, but I still do not understand what you mean.
How exactly do you create the EML file?
Again, all you need to do to make an image show up in the HTML body is to
1. Correctly reference the image in the HTML body using <img src="cid:...">
2. Make sure content id of the attachment isexactly as in (1)
3. Make sure teh attachemnmt is actually in teh EML file.

Which of the following 3 above is not satisfied in your case? *What* exactly
does not work?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
When i create eml file i use CDOEX IMessage interface.
Varun replied to Dmitry Streblechenko
05-Nov-09 04:40 AM
When i create eml file i use CDOEX IMessage interface.
Note->If there is an embeded image in body of mail then IMessage interface
never show it as attachment means if i send a mail without any attachment and
paste a picture in body of mail, when mail receive on exchange server i
access this mail using IMessage interface then IMessage->Attachments->Count
shows always value 0.
Let me write the code how to create eml file

CoInitialize( NULL );
HRESULT hr = S_OK;

IMessagePtr pMsg( __uuidof( Message ) );
IDataSourcePtr pDsrc = NULL;
USES_CONVERSION;
hr = pMsg->get_DataSource(&pDsrc);
hr = pDsrc->raw_Open(  "mail path on exchange server",
NULL,
adModeReadWrite,
adFailIfNotExists,
adOpenSource,
_bstr_t() , _bstr_t() );

pMsg->GetStream()->SaveToFile("eml file name with
path",adSaveCreateOverWrite);
IMessage->HTMLBody keeps html data of mail which also contains image
information like
src="cid:image001.jpg@01CA5A42.D2B24400">

If i check all data from this mail when access using IMessage then it keeps
attachment information also
Content-ID: <image001.jpg@01CA5A42.D2B24400>
Content-Type: image/jpeg;
name="image001.jpg"
Content-Transfer-Encoding: base64
Content-Description: image001.jpg
Content-Location: image001.jpg

SO following 2 points are correct
1. Correctly reference the image in the HTML body using <img src="cid:...">
2. Make sure content id of the attachment isexactly as in (1)

About 3rd point when i create eml file it shows embeded image in attachment
list not in body.

The above points are for when i send a mail using HTML format.
But when i send a mail using rich text format and create eml file using same
IMessage interface then there is no image in eml file.
Post Question To EggHeadCafe