> Where does the definition of IMessage come from? Note that it must be the
> Extended MAPI version of IMessage (defined in MAPIDefs.h), not CDOSYS.
[quoted text clipped - 58 lines]
> >
> > thanks !
Hi, so should I include <mapidefs.h> instead of #immport <cdosys.dll>
if I do that, my code does not compile. If I leave both in, I get
redefinition error.
Dmitry Streblechenko \(MVP\) - 03 Feb 2004 17:30 GMT
What do you mean by "it does not compile"? What is the error?
Yes, you need to include MAPIDefs.h, you must also define USES IID_IMessage:
#define INITGUID
#include <objbase.h>
#define USES_IID_IMessage
#include <mapix.h>
#include <mapitags.h>
#include <mapidefs.h>
#include <mapiutil.h>
#include <mapiguid.h>
also use IID_IMessage instead of (__uuidof(IMessage)
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> > Where does the definition of IMessage come from? Note that it must be the
> > Extended MAPI version of IMessage (defined in MAPIDefs.h), not CDOSYS.
[quoted text clipped - 62 lines]
> if I do that, my code does not compile. If I leave both in, I get
> redefinition error.
yg - 03 Feb 2004 21:07 GMT
> > Where does the definition of IMessage come from? Note that it must be the
> > Extended MAPI version of IMessage (defined in MAPIDefs.h), not CDOSYS.
[quoted text clipped - 62 lines]
> if I do that, my code does not compile. If I leave both in, I get
> redefinition error.
Hi Dmitry , here is what I want to do:
In my event handler 'OnItemSend' I want to get the entire message
going out
including headers. In an MSDN example I saw that you can get the
Stream from an Imessage pointer like this:
IMessage* pMsg = NULL;
IBodyPart* pBp = NULL;
IConfiguration* pConfig = NULL;
Fields* pFlds = NULL;
Field* pFld = NULL;
_Stream* pStm = NULL;
hr=CoCreateInstance(
__uuidof(Message),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IMessage),
(void**)&pMsg);
pMsg->put_To(_bstr_t("\"Xyz Xyz\" <xyz@zxy.com>"));
pMsg->put_From(_bstr_t("\"Xyz Xyz\" <xyz@zxy.com>"));
pMsg->put_Subject(_bstr_t("Test"));
pMsg->AddAttachment(L"c:\\document.doc",L"",L"",&pBp);
pBp->put_ContentMediaType(L"application/msword");
pBp->Release();
pBp = NULL;
pMsg->GetStream(&pStm);
hr = pStm->SaveToFile(L"c:\\savemymessage.eml",adSaveCreateOverWrite);
.
.
.
So from this code snippete I can get the Stream and save it to a file.
But how can I simultae this in my 'OnItemSend' event handler ? How can
I get the message stream there ?
thanks you very much.
Dmitry Streblechenko \(MVP\) - 03 Feb 2004 23:13 GMT
EML (or RFC822) format is not native to Extended MAPI, you would need to
either create the EML file property by property or use a third party library
(e.g. Redemption, url below, see SafeMailItem.SaveAs(path, olRFC822)).
This will not be the exact RFC822 message about to be sent - the real
conversion will be handled by the SMTP transport provider (if that is what
will be used - in case of two Exchange mailboxes the conversion never takes
place).
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> > > Where does the definition of IMessage come from? Note that it must be the
> > > Extended MAPI version of IMessage (defined in MAPIDefs.h), not CDOSYS.
[quoted text clipped - 104 lines]
>
> thanks you very much.
yg - 05 Feb 2004 00:40 GMT
> EML (or RFC822) format is not native to Extended MAPI, you would need to
> either create the EML file property by property or use a third party library
[quoted text clipped - 124 lines]
> >
> > thanks you very much.
Hi Dmitry, so if I add the follwoing to my main header file:
#include <objbase.h>
#include <mapix.h>
#include <mapitags.h>
#include <mapidefs.h>
#include <mapiutil.h>
#include <mapiguid.h>
#define INITGUID
#define USES_IID_IMessage
on top of what's allready included there:
#import <cdosys.dll> no_namespace raw_interfaces_only
#import "c:\program files\common files\system\ado\msado15.dll"
no_namespace raw_interfaces_only
#include "cdosysstr.h"
#include "cdosyserr.h"
and then I try to rebuild the addon, I get the follwoing compile time
errors:
cdosys.tlh(416) : error C2011: 'IMessage' : 'struct' type redefinition
which happens because I am inlduing CDOSYS I assume, but if I don't
include it
I can not work with Interfaces like:
IBodyPart
IConfiguration
which I need inoreder to build an email message and get the MIME
entity.
any suggestions ?
thanks alot.
thanks.
Dmitry Streblechenko \(MVP\) - 05 Feb 2004 05:25 GMT
You should not be referencing CDOSYS at all. IBodyPart and IConfiguration
have nothing to do with anything related to MAPI or Outlook.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> > EML (or RFC822) format is not native to Extended MAPI, you would need to
> > either create the EML file property by property or use a third party library
[quoted text clipped - 165 lines]
>
> thanks.
yg - 06 Feb 2004 18:15 GMT
> You should not be referencing CDOSYS at all. IBodyPart and IConfiguration
> have nothing to do with anything related to MAPI or Outlook.
[quoted text clipped - 187 lines]
> >
> > thanks.
thanks Dmitry, can you tell me the name of the Interface I need to
query for
the redemption COM object. I am using smart pointers (with VC++) so I
am imporing the DLL.
#import "c:\\winnt\systemre32\\redemption.dll"
thanks ...
Dmitry Streblechenko \(MVP\) - 06 Feb 2004 20:47 GMT
SafeMailItem. What are the properties that you are trying to read?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> You should not be referencing CDOSYS at all. IBodyPart and IConfiguration
> have nothing to do with anything related to MAPI or Outlook.
[quoted text clipped - 136 lines]
> > > > pMsg->GetStream(&pStm);
> > > > hr =
pStm->SaveToFile(L"c:\\savemymessage.eml",adSaveCreateOverWrite);
> > > > .
> > > > .
[quoted text clipped - 46 lines]
> >
> > thanks.