Just now, I tried with below code snippet. It behaves differently. I have
taken LPSPropProblemArray.
LPSPropProblemArray pProblems;
try{
MessageBox(NULL,"Trying to copy properties","",MB_OK);//I got this messagebox
hRes = lpMessage -> CopyTo(0, NULL,(LPSPropTagArray)&excludeTags,NULL,
NULL,(LPIID)&IID_IMessage,pIMsg, 0, &pProblems);
MessageBox(NULL,"copied properties","",MB_OK);//I got this messagebox
}catch(...)
{
MessageBox(NULL,"catch block","",MB_OK);
}
if (hRes == S_OK )
MessageBox(NULL,"S_OK ","",MB_OK);
if (hRes == MAPI_E_COLLISION )
MessageBox(NULL,"MAPI_E_COLLISION ","",MB_OK);
if (hRes == MAPI_E_DECLINE_COPY )
MessageBox(NULL,"MAPI_E_DECLINE_COPY ","",MB_OK);
if (hRes == MAPI_E_FOLDER_CYCLE )
MessageBox(NULL,"MAPI_E_FOLDER_CYCLE ","",MB_OK);
if (hRes == MAPI_E_INTERFACE_NOT_SUPPORTED )
MessageBox(NULL,"MAPI_E_INTERFACE_NOT_SUPPORTED ","",MB_OK);
if (hRes == MAPI_E_NO_ACCESS)
MessageBox(NULL,"MAPI_E_NO_ACCESS ","",MB_OK);
if (hRes == S_FALSE)
MessageBox(NULL,"S_FALSE","",MB_OK);
if (SUCCEEDED(hRes)) MessageBox(NULL,"copyto succ","",MB_OK);
else
{
MessageBox(NULL,"copyto fail","",MB_OK);//I got this messagebox
if (pProblems != NULL)
{
int nNoOfStructures = pProblems->cProblem;
FILE* fp = fopen("C:\\Problems.txt","a+");
fprintf(fp,"No Of Problems:: %d\n\n",nNoOfStructures);
fclose(fp);
for (int i = 1; i <= nNoOfStructures; i ++)
{
FILE* fp = fopen("C:\\Problems.txt","a+");
fprintf(fp,"%d\t%d\t%d\n",pProblems->aProblem->ulIndex,pProblems->aProblem->ulPropTag,pProblems->aProblem->scode);
fclose(fp);
}
return S_FALSE;
}
}
else MessageBox(NULL,"problems are not there...","",MB_OK);//I got this
messagebox
I GOT THESE MESSAGES ONLY:
Trying to copy properties
copied properties
copyto fail
problems are not there...
Can you give any suggestions?
How to solve this problem?
For copying properties, should I include any supporting files or dlls while
creating setup?
With regards,
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
Post by Dkds.NaiduThank you for your response. sorry for the last post.
While developing application, it works fine.I got more than 500 mails
backup.Then, I created setup for this application.Now, it has crash problems
while copying properties. With setup, I can create .msg file with 0 bytes
only and it is getting crash.
STDMETHODIMP
CExchangeAddin::OnDelivery(IExchExtCallback *lpExchangeCallback)
{
LPMESSAGE lpMessage = NULL;
LPMDB lpMdb = NULL;
if (SUCCEEDED(lpExchangeCallback->GetObject(&lpMdb, (LPMAPIPROP*)&lpMessage)))
{
char chFilePath[500];
HRESULT hRes = S_OK;
LPSPropValue pSubject = NULL;
CComPtr<IStorage> pStorage;
LPMSGSESS pMsgSession = NULL;
LPMESSAGE pIMsg = NULL;
LPWSTR lpWideCharStr = NULL;
ULONG cbStrSize = 0L;
SizedSPropTagArray ( 7, excludeTags );
USES_CONVERSION;
//Got the complete file path into "chFilePath"
lpWideCharStr = A2W(chFilePath);
LPMALLOC pMalloc = MAPIGetDefaultMalloc();
hRes = ::StgCreateDocfile(lpWideCharStr,STGM_READWRITE |STGM_TRANSACTED
|STGM_CREATE, 0, &pStorage);
hRes = ::StgCreateStorageEx(lpWideCharStr,STGM_READWRITE |STGM_TRANSACTED
|STGM_CREATE,STGFMT_STORAGE,0,
NULL,NULL,IID_IStorage,reinterpret_cast<void**>(&pStorage));
hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
hRes =
::OpenIMsgOnIStg(pMsgSession,MAPIAllocateBuffer,MAPIAllocateMore,MAPIFreeBuffer,pMalloc,NULL,pStorage,NULL, 0, 0, &pIMsg);
hRes = WriteClassStg(pStorage, CLSID_MailMessage );
excludeTags.cValues = 7;
excludeTags.aulPropTag[0] = PR_ACCESS;
excludeTags.aulPropTag[1] = PR_BODY;
excludeTags.aulPropTag[2] = PR_RTF_SYNC_BODY_COUNT;
excludeTags.aulPropTag[3] = PR_RTF_SYNC_BODY_CRC;
excludeTags.aulPropTag[4] = PR_RTF_SYNC_BODY_TAG;
excludeTags.aulPropTag[5] = PR_RTF_SYNC_PREFIX_COUNT;
excludeTags.aulPropTag[6] = PR_RTF_SYNC_TRAILING_COUNT;
hRes = lpMessage -> CopyTo(0,
NULL,(LPSPropTagArray)&excludeTags,NULL,
NULL,(LPIID)&IID_IMessage,pIMsg, 0, NULL );
/**************************************/
When copying properties from lpMessage to pIMsg, Outlook gets
crash problem.I tried with excludeTags parameter and without excludeTags
parameter(ie. NULL).
/**************************************/
}
}
Thanks in advance.
With regards,
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
Post by Dmitry StreblechenkoIMessage on IStorage is returned in the pIMsg variable by OpenIMsgOnIStg(),
but you are using the pIBackupMsg variable when calling CopyTo().
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Dkds.NaiduThank you for your immediate response.
Application crashed where copying properties from one message to another
message.
char chFilePath[500];
HRESULT hRes = S_OK;
LPSPropValue pSubject = NULL;
CComPtr<IStorage> pStorage;
LPMSGSESS pMsgSession = NULL;
LPMESSAGE pIBackupMsg = NULL;
LPWSTR lpWideCharStr = NULL;
ULONG cbStrSize = 0L;
SizedSPropTagArray ( 7, excludeTags );
//Got the complete file path into "chFilePath"
lpWideCharStr = A2W(chFilePath);
LPMALLOC pMalloc = MAPIGetDefaultMalloc();
hRes = ::StgCreateDocfile(lpWideCharStr,STGM_READWRITE |STGM_TRANSACTED
|STGM_CREATE, 0, &pStorage);
hRes = ::StgCreateStorageEx(lpWideCharStr,STGM_READWRITE |STGM_TRANSACTED
|STGM_CREATE,STGFMT_STORAGE,0,
NULL,NULL,IID_IStorage,reinterpret_cast<void**>(&pStorage));
hRes = ::OpenIMsgSession(pMalloc, 0, &pMsgSession);
hRes =
::OpenIMsgOnIStg(pMsgSession,MAPIAllocateBuffer,MAPIAllocateMore,MAPIFreeBuffer,pMalloc,NULL,pStorage,NULL,
0, 0, &pIMsg);
hRes = WriteClassStg(pStorage, CLSID_MailMessage );
excludeTags.cValues = 7;
excludeTags.aulPropTag[0] = PR_ACCESS;
excludeTags.aulPropTag[1] = PR_BODY;
excludeTags.aulPropTag[2] = PR_RTF_SYNC_BODY_COUNT;
excludeTags.aulPropTag[3] = PR_RTF_SYNC_BODY_CRC;
excludeTags.aulPropTag[4] = PR_RTF_SYNC_BODY_TAG;
excludeTags.aulPropTag[5] = PR_RTF_SYNC_PREFIX_COUNT;
excludeTags.aulPropTag[6] = PR_RTF_SYNC_TRAILING_COUNT;
hRes = lpOriginalMessage -> CopyTo(0,
NULL,(LPSPropTagArray)&excludeTags,NULL,
NULL,(LPIID)&IID_IMessage,pIBackupMsg, 0, NULL );
/**************************************/
When copying properties from lpOriginalMessage to pIBackupMsg, Outlook gets
crash problem.I tried with excludeTags parameter and without excludeTags
parameter(ie. NULL).
/**************************************/
Thanks in advance.
With regards,
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
Post by Dmitry StreblechenkoWhat is the error returned by CopyTo()?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Dkds.NaiduHi Dmitry,
I followed http://support.microsoft.com/?kbid=171907 article.
I can take backup of all incoming mails through programmatically.I can do
backup and restore of hundreds of mails. Really, it works fine. But, after
creating setup of our application which is fails at
lpMessage->CopyTo(......)
function everytime. How can I solve this problem? after creating setup only,
it has this problem.
Thanks in advance.
With regards,
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
Post by Dmitry StreblechenkoI have to disagree: you will have problems with any format. MIME might
be
a
good alternative, but it poses even greater conversion problems, especially
with the MAPI specific features, such as pure RTF messages, embedded OLE
attachments, etc.
You can of course develop your own format, but I suspect that it will take
you months to design and debug it to bring the number of bugs down to the
level that you will encounter with the MSG format.
The biggest MSG format problem is the messages with a large # of
recipients,
but it easy to work around it by ussing StgCreateStorageEx (Windows
2000
and
up) rather than StgCreateDocfile.
http://support.microsoft.com/?kbid=171907
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Stephen GriffinI would NOT use MSG as a means for message archiving/backup. This message
format is not suitable for storing all the variety of messages you will
encounter in the wild. In particular, deeply nested messages and messages
with large numbers of recipients and/or attachments will present
unsolvable
problems with this format. Also, you lose a great deal in message
fidelity
in conversion to and from this format.
You will be much better off developing your own format in which to
archive
the messages, or (since it looks like this may be an in-house project),
locating a third party who has already done this work.
Steve
Post by Dkds.NaiduHi Dmitry,
I am trying to design a utilty in Outlook where the
user
is
given the provision of saving a copy of the every incoming mail in
a
desired
location (currently in our server).
This utility will enable the user to resore/downlaod
his
mails
from the server once the user moves from his current place to a
different
geographical location.
Currently am able to capture all the mails (
OnDelivery()
method of IExchExtSessionEvents) .How to save this mails in .MSG
format
with
UNICODE support?
I wonder whether am proceeding in the right direction in my quest
to
design
the above mentioned utilty!
1. How can I save the incoming mail in .MSG format with UNICODE
support.
Note: I can trap the incoming mail. How to save this mail with .msg
format
and with unicode support.
2. Can I restore mails if I save mails in .msg with unicode support.
Seeking your guidance
Best regards,
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
Post by Dmitry StreblechenkoWhat kind of backup? *Where* do you want to store the messages?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Dkds.NaiduI love you Dmitry. Really you are giving lot of help.
Anyway, I have to take backup of all incoming mails and restore
all