Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert MIMEToMAPI and MAPIToMIMEStm

171 views
Skip to first unread message

arthurromanoff

unread,
May 2, 2008, 10:03:09 AM5/2/08
to
Hi everybody.... I have following problem...

I'm converting EML file to MAPI Message -it's ok,
But when I try to convert MAPI Message to EML file I have following problem... The body between original EML file and converted EML file is different!!!

I don't understand what happening... This is my short code...

HRESULT ConvertMimeToMapi(LPMESSAGE lpMessage)
{
pConverterSession = CoCreateInstanse(....)
hr = pConverterSession_->SetEncoding(IET_QP);
hr = pConverterSession_->SetSaveFormat(SAVE_RFC822);
hr = pConverterSession_->MIMEToMAPI(pMimeStream, lpMessage , NULL, CCSF_SMTP | CCSF_INCLUDE_BCC);
}

// Transform EML to MSG
HRESULT ConvertMapiToMime(LPMESSAGE lpMessage)
{
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
pConverterSession = CoCreateInstanse(....)
hr = pConverterSession_->SetEncoding(IET_QP);
hr = pConverterSession_->SetSaveFormat(SAVE_RFC822);
hr = pConverterSession_->MAPIToMIMEStm(lpMessage,
pStream,
CCSF_SMTP |
CCSF_INCLUDE_BCC);
hr = pStream->Commit(0);
}

Dmitry Streblechenko

unread,
May 2, 2008, 1:22:23 PM5/2/08
to
And the difference is?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<Arthur Romanoff> wrote in message news:20085210...@yandex.ru...

Stephen Griffin [MSFT]

unread,
May 2, 2008, 2:13:02 PM5/2/08
to
Yes - there will be differences. The composition of those two functions (in
either order) is not guaranteed to be idempotent. This isn't even a
reasonable goal, considering the mapping between MAPI properties and MIME
headers isn't 1-1. As an example, there are properties that are per recpient
in MAPI who's closest analogue in MIME is a per message header. Consider
also the issue of bodypart seperators. They exist in MIME, but MAPI has no
use for them.

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:OXR3WkHr...@TK2MSFTNGP03.phx.gbl...

arthurromanoff

unread,
May 4, 2008, 4:53:30 AM5/4/08
to
The difference only Body, I didn't set SetSaveFormatand when reading body I'm setting Engoding from MessageStream CharSet - and... Everythink is ok .... It's true?

Web Service and MAPI

unread,
Jul 2, 2008, 4:09:13 AM7/2/08
to
I have problem when I'm converting eml to msg with Japanese format. The body,
which contains Japanese text shows correctly, but Subject, and recipinet
dysplay name shows incorrect. What can I do? Pls help. Thenks very much.

This is part of my code

HRESULT EmlToMsgConvertor::ConvertMimeToMapi(IUnknown* pStream, LPMESSAGE
lpMessage)
{
USES_CONVERSION;

HRESULT hr = S_OK;

CComPtr<IStream> pMimeStream;


hr = pStream->QueryInterface(IID_IStream, (void**)&pMimeStream);
if (FAILED(hr))
{
throw _com_error(hr);
}

/* if (SUCCEEDED(hr))
{
hr = pConverterSession_->SetEncoding(IET_UNKNOWN);
}*/

if (SUCCEEDED(hr))
{
hr = pConverterSession_->SetSaveFormat(SAVE_RFC822);
}


if (SUCCEEDED(hr))
{
hr = pConverterSession_->MIMEToMAPI(pMimeStream, lpMessage , NULL, 0);
}

return hr;
}

Dmitry Streblechenko

unread,
Jul 2, 2008, 11:33:15 AM7/2/08
to
Is that a Unicode or ANSI MSG file?

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

"Web Service and MAPI" <WebServi...@discussions.microsoft.com> wrote
in message news:AA889D42-E50D-4C11...@microsoft.com...

Web Service and MAPI

unread,
Jul 3, 2008, 3:56:11 AM7/3/08
to
I set OpenIMsgOnIStg as Unicode, because I must support Japanese mail. I'm
resolving this problem, but when I conver MSG to Com.IStream a have different
bytes array count. And I don't call
hr = pConverterSession_->SetEncoding(...);
hr = pConverterSession_->SetSaveFormat(...);

Dmitry Streblechenko

unread,
Jul 3, 2008, 6:14:22 PM7/3/08
to
I am not sure what you are saying: so does it work Ok if you create Unicode
MSG file?
What do you mean by " have different bytes array count". Why does it matter?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Web Service and MAPI" <WebServi...@discussions.microsoft.com> wrote
in message news:3216621F-9E6B-4384...@microsoft.com...

arthurromanoff

unread,
Jul 16, 2008, 4:08:38 AM7/16/08
to
I have the following eml file!!!!

Message-ID: <16159836.1075855377439.JavaMail.evans@thyme>
Date: Fri, 7 Dec 2001 10:06:42 -0800 (PST)
From: heather...@enron.com
To: k..allen@enron.com
Subject: RE: West Position
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-From: Dunton, Heather </O=ENRON/OU=NA/CN=RECIPIENTS/CN=HDUNTON>
X-To: Allen, Phillip K. </O=ENRON/OU=NA/CN=RECIPIENTS/CN=Pallen>
X-cc:
X-bcc:
X-Folder: \Phillip_Allen_Jan2002_1\Allen, Phillip K.\Inbox
X-Origin: Allen-P
X-FileName: pallen (Non-Privileged).pst

Please let me know if you still need Curve Shift.

Thanks,
Heather
-----Original Message-----
From: Allen, Phillip K.
Sent: Friday, December 07, 2001 5:14 AM
To: Dunton, Heather
Subject: RE: West Position

Heather,

Did you attach the file to this email?

-----Original Message-----
From: Dunton, Heather
Sent: Wednesday, December 05, 2001 1:43 PM
To: Allen, Phillip K.; Belden, Tim
Subject: FW: West Position

Attached is the Delta position for 1/16, 1/30, 6/19, 7/13, 9/21


When I converted eml to msg file I have the following problem. Some parts of email I see in body. For Example.


Message in Body:

Content-Transfer-Encoding: 7bit

Thanks,
Heather
-----Original Message-----
From: Allen, Phillip K.
Sent: Friday, December 07, 2001 5:14 AM
To: Dunton, Heather
Subject: RE: West Position

Heather,

Did you attach the file to this email?

-----Original Message-----
From: Dunton, Heather
Sent: Wednesday, December 05, 2001 1:43 PM
To: Allen, Phillip K.; Belden, Tim
Subject: FW: West Position

Attached is the Delta position for 1/16, 1/30, 6/19, 7/13, 9/21

The string "Please let me know if you still need Curve Shift." is missing!!! What is problem? I don't know.......

Parts of my code is:

if (SUCCEEDED(hr))
{
hr = ConverterSession_->SetEncoding(IET_QP);
}

if (SUCCEEDED(hr))
{
hr = pConverterSession_->SetSaveFormat(SAVE_RFC822);
}


if (SUCCEEDED(hr))
{

Web Service and MAPI

unread,
Jul 16, 2008, 5:06:40 AM7/16/08
to

Heather,


Message in Body:

Content-Transfer-Encoding: 7bit

Heather,

if (SUCCEEDED(hr))
{
hr = pConverterSession_->SetSaveFormat(SAVE_RFC822);
}


if (SUCCEEDED(hr))
{
hr = pConverterSession_->MIMEToMAPI(pMimeStream, lpMessage , NULL,

CCSF_SMTP | CCSF_INCLUDE_BCC);
}

Dmitry Streblechenko

unread,
Jul 16, 2008, 1:48:28 PM7/16/08
to
Hard to see what the real data is, but my bet is that you have a mix of
Windows (0xD, 0xA) and Unix line breaks (0xD).
Look at the EML file in a hex editor to see if you can spot anything.

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

<Arthur Romanoff> wrote in message news:200871648...@yandex.ru...

Web Service and MAPI

unread,
Jul 17, 2008, 2:56:05 AM7/17/08
to
This is original eml file.

X-Account-Key: account2
X-UIDL: GmailId11808d60b0e05f30
X-Mozilla-Status: 0001
X-Mozilla-Status2: 10000000
X-Mozilla-Keys:

Delivered-To: arthur....@linkgard.com
Received: by 10.115.110.10 with SMTP id n10cs29781wam;
Mon, 11 Feb 2008 06:11:30 -0800 (PST)
Received: by 10.78.185.15 with SMTP id i15mr15037838huf.61.1202739088278;
Mon, 11 Feb 2008 06:11:28 -0800 (PST)
Return-Path: <pargev.g...@linkgard.com>
Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.158])
by mx.google.com with ESMTP id
n10si18845583mue.18.2008.02.11.06.11.27;
Mon, 11 Feb 2008 06:11:28 -0800 (PST)
Received-SPF: neutral (google.com: 72.14.220.158 is neither permitted nor
denied by best guess record for domain of pargev.g...@linkgard.com)
client-ip=72.14.220.158;
Authentication-Results: mx.google.com; spf=neutral (google.com:
72.14.220.158 is neither permitted nor denied by best guess record for domain
of pargev.g...@linkgard.com) smtp.mail=pargev.g...@linkgard.com
Received: by fg-out-1718.google.com with SMTP id d23so4542840fga.27
for <arthur....@linkgard.com>; Mon, 11 Feb 2008 06:11:26 -0800
(PST)
Received: by 10.86.90.2 with SMTP id n2mr15165861fgb.66.1202739086594;
Mon, 11 Feb 2008 06:11:26 -0800 (PST)
Return-Path: <pargev.g...@linkgard.com>
Received: from ?10.0.10.184? ( [91.103.31.34])
by mx.google.com with ESMTPS id b17sm14876226fka.4.2008.02.11.06.11.03
(version=TLSv1/SSLv3 cipher=RC4-MD5);
Mon, 11 Feb 2008 06:11:20 -0800 (PST)
Message-ID: <47B05780...@linkgard.com>
Date: Mon, 11 Feb 2008 18:11:12 +0400
From: Pargev Ghazaryan <pargev.g...@linkgard.com>
User-Agent: Thunderbird 2.0.0.9 (Windows/20071031)
MIME-Version: 1.0
To: Suren Samarchyan <suren.sa...@linkgard.com>,
Arthur Romanov <arthur....@linkgard.com>,
Ashot Petrosyan <ashot.p...@linkgard.com>,
garegin....@linkgard.com,
Christian Garbis <christia...@linkgard.com>,
Hovanes Manucharyan <o...@linkgard.com>,
LinkGard QA Team <q...@linkgard.com>,
Hrachya Petrosyan <hrachya....@linkgard.com>
Subject: Merge1: Meeting Minutes for Feb, 11 2008
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi all,

Please find attached the meeting agenda and minutes. I will strongly
recommend to find time and read it. If nothing is messed/ missed there,
than these minutes may serve as baseline for our efforts on Merge1.

Please let me know if any question...
Thanks,
Pargev

But, MIMETOMAPI cannot correct convert Mime to LPMESSAGE.
I don't find Unicode symbol in this file. I don't know, what can I do....
And when file has multipart mode the convertation finished success.....

Dmitry Streblechenko

unread,
Jul 17, 2008, 1:00:07 PM7/17/08
to
If you have a mix of different style line breaks, there is no chance I will
see that if you paste the MIME message into the body of your post.
Again, what do you see in a binary editor?

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

"Web Service and MAPI" <WebServi...@discussions.microsoft.com> wrote

in message news:3E426463-9CEA-48E3...@microsoft.com...

0 new messages