Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Tue, 22 Apr 2008 06:04:00 -0700,    group: microsoft.public.platformsdk.mapi        back       


MAPI - Mail size differs when stored as .MSG programatically   
Hi,
I have a issue reg the mail size that is saved in MSG format through MAPI.
 
Im creating a IStorage object and storing my mail into it in .MSG format.
When I check the size of the saved message, it comes around 200KB. But, if  
I try to save the same mail from outlook - File/SaveAs, the size comes around 
10kb. 
 
I dont have problems with very small mails, but when a mail around 2MB is 
sent, my application is failing because the size becomes 8MB after the mail 
is saved in MSG format through the application.

Im clueless as to what makes this much of size and how to rectify this. 

Can anybody throw some light on this.
date: Tue, 22 Apr 2008 06:04:00 -0700   author:   kavitha

Re: MAPI - Mail size differs when stored as .MSG programatically   
You really need to show the relevant snippets of your code.
What happens if you simply create an MSG file without writing any MAPI 
properties?
What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg? Any 
large binary or string properties?

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"kavitha"  wrote in message 
news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
> Hi,
> I have a issue reg the mail size that is saved in MSG format through MAPI.
>
> Im creating a IStorage object and storing my mail into it in .MSG format.
> When I check the size of the saved message, it comes around 200KB. But, if
> I try to save the same mail from outlook - File/SaveAs, the size comes 
> around
> 10kb.
>
> I dont have problems with very small mails, but when a mail around 2MB is
> sent, my application is failing because the size becomes 8MB after the 
> mail
> is saved in MSG format through the application.
>
> Im clueless as to what makes this much of size and how to rectify this.
>
> Can anybody throw some light on this.
>
date: Wed, 23 Apr 2008 10:54:54 -0700   author:   Dmitry Streblechenko

Re: MAPI - Mail size differs when stored as .MSG programatically   
Hi Dmitry,

Im pasting my code snippet below:

pMalloc = MAPIGetDefaultMalloc();
		
STGOPTIONS myOpts = {0};
myOpts.usVersion = 1;//STGOPTIONS_VERSION;
myOpts.reserved = 0;
myOpts.ulSectorSize = 4096;
myOpts.pwcsTemplateFile = 0;
			
// Convert new file name to WideChar
LPWSTR	lpWideCharStr = NULL;
hRes = ( AnsiToUnicode( szFileName, &lpWideCharStr ) );

hRes = ( ::StgCreateStorageEx(lpWideCharStr,
	STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH, 
                STGFMT_DOCFILE, 0, &myOpts,	0,__uuidof( IStorage ),
                ( LPVOID* ) &pStorage ) );

hRes = pStorage->CreateStream( lpWideCharStr,
	STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH, 
	0, 0, &pMailStream );
					
if( pStorage )
{
	// Open an IMessage session.
	hRes = (::OpenIMsgSession( pMalloc, 0, &pMsgSession ) );
				
	// Open an IMessage interface on an IStorage object
	hRes = (::OpenIMsgOnIStg( pMsgSession,
	MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer,  
                pMalloc, NULL, pStorage, NULL, 0, 0, &pIMsg ) );
					
	hRes = (WriteClassStg( pStorage, CLSID_MailMessage ) );
							
                // copy message properties to IMessage object opened on top 
of IStorage.
                 hRes = ( lpMessage->CopyTo( 0, NULL, NULL,
    	              NULL, NULL,( LPIID) &IID_IMessage,
	              pIMsg, 0, &lpProblems ) );
		}
	MAPIFreeBuffer( lpProblems );
						
	// save changes to IMessage object.
	hRes = ( pIMsg->SaveChanges(KEEP_OPEN_READWRITE ) );
					
	// save changes in storage of new doc file
	hRes = ( pStorage->Commit( STGC_DEFAULT ) );
						
	hRes = pStorage->Stat( pstatstg, 0 );
					
}

> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg?
I didnt understand what do you mean by this. pls elaborate.

"Dmitry Streblechenko" wrote:

> You really need to show the relevant snippets of your code.
> What happens if you simply create an MSG file without writing any MAPI 
> properties?
> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg? Any 
> large binary or string properties?
> 
> -- 
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool
> -
> "kavitha"  wrote in message 
> news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
> > Hi,
> > I have a issue reg the mail size that is saved in MSG format through MAPI.
> >
> > Im creating a IStorage object and storing my mail into it in .MSG format.
> > When I check the size of the saved message, it comes around 200KB. But, if
> > I try to save the same mail from outlook - File/SaveAs, the size comes 
> > around
> > 10kb.
> >
> > I dont have problems with very small mails, but when a mail around 2MB is
> > sent, my application is failing because the size becomes 8MB after the 
> > mail
> > is saved in MSG format through the application.
> >
> > Im clueless as to what makes this much of size and how to rectify this.
> >
> > Can anybody throw some light on this.
> > 
> 
> 
>
date: Wed, 23 Apr 2008 21:26:01 -0700   author:   kavitha

Re: MAPI - Mail size differs when stored as .MSG programatically   
Hi kavitha,

> STGOPTIONS myOpts = {0};
> myOpts.usVersion = 1;//STGOPTIONS_VERSION;
> myOpts.reserved = 0;
> myOpts.ulSectorSize = 4096;

Try the default sector size of 512.

--
SvenC
date: Thu, 24 Apr 2008 09:05:40 +0200   author:   SvenC am

Re: MAPI - Mail size differs when stored as .MSG programatically   
You're seeing this because you passed STGM_NOSCRATCH. I mentioned this (in 
passing) here:
http://blogs.msdn.com/stephen_griffin/archive/2008/01/04/a-brief-history-of-mfcmapi.aspx

"kavitha"  wrote in message 
news:CB0ED482-90B8-411F-9D1F-5773D23BEA58@microsoft.com...
> Hi Dmitry,
>
> Im pasting my code snippet below:
>
> pMalloc = MAPIGetDefaultMalloc();
>
> STGOPTIONS myOpts = {0};
> myOpts.usVersion = 1;//STGOPTIONS_VERSION;
> myOpts.reserved = 0;
> myOpts.ulSectorSize = 4096;
> myOpts.pwcsTemplateFile = 0;
>
> // Convert new file name to WideChar
> LPWSTR lpWideCharStr = NULL;
> hRes = ( AnsiToUnicode( szFileName, &lpWideCharStr ) );
>
> hRes = ( ::StgCreateStorageEx(lpWideCharStr,
> STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH,
>                STGFMT_DOCFILE, 0, &myOpts, 0,__uuidof( IStorage ),
>                ( LPVOID* ) &pStorage ) );
>
> hRes = pStorage->CreateStream( lpWideCharStr,
> STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH,
> 0, 0, &pMailStream );
>
> if( pStorage )
> {
> // Open an IMessage session.
> hRes = (::OpenIMsgSession( pMalloc, 0, &pMsgSession ) );
>
> // Open an IMessage interface on an IStorage object
> hRes = (::OpenIMsgOnIStg( pMsgSession,
> MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer,
>                pMalloc, NULL, pStorage, NULL, 0, 0, &pIMsg ) );
>
> hRes = (WriteClassStg( pStorage, CLSID_MailMessage ) );
>
>                // copy message properties to IMessage object opened on top
> of IStorage.
>                 hRes = ( lpMessage->CopyTo( 0, NULL, NULL,
>                  NULL, NULL,( LPIID) &IID_IMessage,
>               pIMsg, 0, &lpProblems ) );
> }
> MAPIFreeBuffer( lpProblems );
>
> // save changes to IMessage object.
> hRes = ( pIMsg->SaveChanges(KEEP_OPEN_READWRITE ) );
>
> // save changes in storage of new doc file
> hRes = ( pStorage->Commit( STGC_DEFAULT ) );
>
> hRes = pStorage->Stat( pstatstg, 0 );
>
> }
>
>> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg?
> I didnt understand what do you mean by this. pls elaborate.
>
> "Dmitry Streblechenko" wrote:
>
>> You really need to show the relevant snippets of your code.
>> What happens if you simply create an MSG file without writing any MAPI
>> properties?
>> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg? Any
>> large binary or string properties?
>>
>> -- 
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy  - Outlook, CDO
>> and MAPI Developer Tool
>> -
>> "kavitha"  wrote in message
>> news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
>> > Hi,
>> > I have a issue reg the mail size that is saved in MSG format through 
>> > MAPI.
>> >
>> > Im creating a IStorage object and storing my mail into it in .MSG 
>> > format.
>> > When I check the size of the saved message, it comes around 200KB. But, 
>> > if
>> > I try to save the same mail from outlook - File/SaveAs, the size comes
>> > around
>> > 10kb.
>> >
>> > I dont have problems with very small mails, but when a mail around 2MB 
>> > is
>> > sent, my application is failing because the size becomes 8MB after the
>> > mail
>> > is saved in MSG format through the application.
>> >
>> > Im clueless as to what makes this much of size and how to rectify this.
>> >
>> > Can anybody throw some light on this.
>> >
>>
>>
>>
date: Thu, 24 Apr 2008 08:53:09 -0400   author:   Stephen Griffin [MSFT]

Re: MAPI - Mail size differs when stored as .MSG programatically   
Thank you Stepen and SvenC. I have used both the solutions and it seems to 
work well only when both are implemented. I have removed the STGM_NOSCRATCH 
and set the default sector size of 512. 
Thank you both once again:)))

"Stephen Griffin [MSFT]" wrote:

> You're seeing this because you passed STGM_NOSCRATCH. I mentioned this (in 
> passing) here:
> http://blogs.msdn.com/stephen_griffin/archive/2008/01/04/a-brief-history-of-mfcmapi.aspx
> 
> "kavitha"  wrote in message 
> news:CB0ED482-90B8-411F-9D1F-5773D23BEA58@microsoft.com...
> > Hi Dmitry,
> >
> > Im pasting my code snippet below:
> >
> > pMalloc = MAPIGetDefaultMalloc();
> >
> > STGOPTIONS myOpts = {0};
> > myOpts.usVersion = 1;//STGOPTIONS_VERSION;
> > myOpts.reserved = 0;
> > myOpts.ulSectorSize = 4096;
> > myOpts.pwcsTemplateFile = 0;
> >
> > // Convert new file name to WideChar
> > LPWSTR lpWideCharStr = NULL;
> > hRes = ( AnsiToUnicode( szFileName, &lpWideCharStr ) );
> >
> > hRes = ( ::StgCreateStorageEx(lpWideCharStr,
> > STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH,
> >                STGFMT_DOCFILE, 0, &myOpts, 0,__uuidof( IStorage ),
> >                ( LPVOID* ) &pStorage ) );
> >
> > hRes = pStorage->CreateStream( lpWideCharStr,
> > STGM_READWRITE | STGM_TRANSACTED | STGM_CREATE | STGM_NOSCRATCH,
> > 0, 0, &pMailStream );
> >
> > if( pStorage )
> > {
> > // Open an IMessage session.
> > hRes = (::OpenIMsgSession( pMalloc, 0, &pMsgSession ) );
> >
> > // Open an IMessage interface on an IStorage object
> > hRes = (::OpenIMsgOnIStg( pMsgSession,
> > MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer,
> >                pMalloc, NULL, pStorage, NULL, 0, 0, &pIMsg ) );
> >
> > hRes = (WriteClassStg( pStorage, CLSID_MailMessage ) );
> >
> >                // copy message properties to IMessage object opened on top
> > of IStorage.
> >                 hRes = ( lpMessage->CopyTo( 0, NULL, NULL,
> >                  NULL, NULL,( LPIID) &IID_IMessage,
> >               pIMsg, 0, &lpProblems ) );
> > }
> > MAPIFreeBuffer( lpProblems );
> >
> > // save changes to IMessage object.
> > hRes = ( pIMsg->SaveChanges(KEEP_OPEN_READWRITE ) );
> >
> > // save changes in storage of new doc file
> > hRes = ( pStorage->Commit( STGC_DEFAULT ) );
> >
> > hRes = pStorage->Stat( pstatstg, 0 );
> >
> > }
> >
> >> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg?
> > I didnt understand what do you mean by this. pls elaborate.
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> You really need to show the relevant snippets of your code.
> >> What happens if you simply create an MSG file without writing any MAPI
> >> properties?
> >> What do you see in OutlookSpy when you click Misc | OpenIMsgOnIStg? Any
> >> large binary or string properties?
> >>
> >> -- 
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy  - Outlook, CDO
> >> and MAPI Developer Tool
> >> -
> >> "kavitha"  wrote in message
> >> news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
> >> > Hi,
> >> > I have a issue reg the mail size that is saved in MSG format through 
> >> > MAPI.
> >> >
> >> > Im creating a IStorage object and storing my mail into it in .MSG 
> >> > format.
> >> > When I check the size of the saved message, it comes around 200KB. But, 
> >> > if
> >> > I try to save the same mail from outlook - File/SaveAs, the size comes
> >> > around
> >> > 10kb.
> >> >
> >> > I dont have problems with very small mails, but when a mail around 2MB 
> >> > is
> >> > sent, my application is failing because the size becomes 8MB after the
> >> > mail
> >> > is saved in MSG format through the application.
> >> >
> >> > Im clueless as to what makes this much of size and how to rectify this.
> >> >
> >> > Can anybody throw some light on this.
> >> >
> >>
> >>
> >> 
> 
> 
>
date: Fri, 25 Apr 2008 03:23:00 -0700   author:   kavitha

Re: MAPI - Mail size differs when stored as .MSG programatically   
Thank you Stepen and SvenC. I have used both the solutions and it seems to 
work well only when both are implemented. I have removed the STGM_NOSCRATCH 
and set the default sector size of 512. 
Thank you both once again

"SvenC" wrote:

> Hi kavitha,
> 
> > STGOPTIONS myOpts = {0};
> > myOpts.usVersion = 1;//STGOPTIONS_VERSION;
> > myOpts.reserved = 0;
> > myOpts.ulSectorSize = 4096;
> 
> Try the default sector size of 512.
> 
> --
> SvenC
>
date: Fri, 25 Apr 2008 03:23:01 -0700   author:   kavitha

Re: MAPI - Mail size differs when stored as .MSG programatically   
"kavitha"  wrote in message 
news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
> Hi,
> I have a issue reg the mail size that is saved in MSG format through MAPI.
>
> Im creating a IStorage object and storing my mail into it in .MSG format.
> When I check the size of the saved message, it comes around 200KB. But, if
> I try to save the same mail from outlook - File/SaveAs, the size comes around
> 10kb.

I have a somewhat similar issue. When I save .MSG files programmatically they
are never the EXACT same size as what Outlook creates when you drag a message
to the desktop. Is this the nature of LPSTORAGE?

OutlookSpy is yet a different size as well! By the way OutlookSpy does not create
.msg correctly if the message is entirely in Unicode format (subject and body).

I should mention that I am creating .msg files via StgCreateDocfileOnILockBytes. I only
write them to disk when I need to.
date: Wed, 30 Apr 2008 17:22:50 -0500   author:   na

Re: MAPI - Mail size differs when stored as .MSG programatically   
Do you select the Unicode MSG format when saving from OutlookSpy?

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"na"  wrote in message 
news:enJG7CxqIHA.2208@TK2MSFTNGP04.phx.gbl...
>
> "kavitha"  wrote in message 
> news:152992FF-1C4C-40AE-A7AF-7C5ADCBE80DB@microsoft.com...
>> Hi,
>> I have a issue reg the mail size that is saved in MSG format through 
>> MAPI.
>>
>> Im creating a IStorage object and storing my mail into it in .MSG format.
>> When I check the size of the saved message, it comes around 200KB. But, 
>> if
>> I try to save the same mail from outlook - File/SaveAs, the size comes 
>> around
>> 10kb.
>
> I have a somewhat similar issue. When I save .MSG files programmatically 
> they
> are never the EXACT same size as what Outlook creates when you drag a 
> message
> to the desktop. Is this the nature of LPSTORAGE?
>
> OutlookSpy is yet a different size as well! By the way OutlookSpy does not 
> create
> .msg correctly if the message is entirely in Unicode format (subject and 
> body).
>
> I should mention that I am creating .msg files via 
> StgCreateDocfileOnILockBytes. I only
> write them to disk when I need to.
>
>
date: Wed, 30 Apr 2008 15:39:57 -0700   author:   Dmitry Streblechenko

Re: MAPI - Mail size differs when stored as .MSG programatically   
"Dmitry Streblechenko"  wrote in message

> Do you select the Unicode MSG format when saving from OutlookSpy?

Dmitry,
My humble apologies. I did not realize that was an option.

Your saving the file correctly and your file is the EXACT same byte size as mine.
But the file are NOT identical. Why would this be the case???

As far the size difference when dragging from Outlook itself it seems that Outlook
is using an exclude of some kind and you and I are not...
date: Wed, 30 Apr 2008 21:14:40 -0500   author:   na

Re: MAPI - Mail size differs when stored as .MSG programatically   
Firstly, why is the exact file size important?
Some properties are excluded (no reason to save PR_ENTRYID, who knows what 
exacty Outlook skips?), and I suspect that the order in which the propertis 
are written is also imporatnt.

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"na"  wrote in message 
news:eIKieEzqIHA.4928@TK2MSFTNGP04.phx.gbl...
> "Dmitry Streblechenko"  wrote in message
>
>> Do you select the Unicode MSG format when saving from OutlookSpy?
>
> Dmitry,
> My humble apologies. I did not realize that was an option.
>
> Your saving the file correctly and your file is the EXACT same byte size 
> as mine.
> But the file are NOT identical. Why would this be the case???
>
> As far the size difference when dragging from Outlook itself it seems that 
> Outlook
> is using an exclude of some kind and you and I are not...
>
>
date: Thu, 1 May 2008 09:26:25 -0700   author:   Dmitry Streblechenko

Re: MAPI - Mail size differs when stored as .MSG programatically   
"Dmitry Streblechenko"  wrote in message news:e8%

> Firstly, why is the exact file size important?
> Some properties are excluded (no reason to save PR_ENTRYID, who knows what exacty Outlook skips?), and I suspect that 
> the order in which the propertis are written is also imporatnt.

Well in this wonderful world of mapi just trying to find out if something is done correctly
or not...
date: Thu, 1 May 2008 12:52:26 -0500   author:   na

Re: MAPI - Mail size differs when stored as .MSG programatically   
There is more than one way to skin an MSG file :-)

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"na"  wrote in message 
news:e8kGgQ7qIHA.4912@TK2MSFTNGP03.phx.gbl...
> "Dmitry Streblechenko"  wrote in message news:e8%
>
>> Firstly, why is the exact file size important?
>> Some properties are excluded (no reason to save PR_ENTRYID, who knows 
>> what exacty Outlook skips?), and I suspect that the order in which the 
>> propertis are written is also imporatnt.
>
> Well in this wonderful world of mapi just trying to find out if something 
> is done correctly
> or not...
>
>
date: Thu, 1 May 2008 16:46:00 -0700   author:   Dmitry Streblechenko

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us