|
|
|
date: Tue, 22 Apr 2008 06:04:00 -0700,
group: microsoft.public.platformsdk.mapi
back
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
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
|
|