Discussion:
The "Closed Envelope" issue...
(too old to reply)
Volker Bartheld
2003-11-14 18:19:41 UTC
Permalink
Hi!

When I programmatically create a message in a folder, OL2000 shows - by
default - a *closed* envelope. This icon doesn't change even when I
doubleclick the message and browse it in an inspector.

How can I change that behaviour?

Any hints?


THX,

Volker
Dmitry Streblechenko
2003-11-14 23:39:34 UTC
Permalink
Did you set the PR_MESSAGE_CLASS correctly (e.g. IPM.Note)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Volker Bartheld
Hi!
When I programmatically create a message in a folder, OL2000 shows - by
default - a *closed* envelope. This icon doesn't change even when I
doubleclick the message and browse it in an inspector.
How can I change that behaviour?
Any hints?
THX,
Volker
Volker Bartheld
2003-11-17 16:54:39 UTC
Permalink
Hi Dmitry!
Post by Dmitry Streblechenko
Post by Volker Bartheld
When I programmatically create a message in a folder, OL2000 shows - by
default - a *closed* envelope. This icon doesn't change even when I
doubleclick the message and browse it in an inspector.
How can I change that behaviour?
On Fri, 14 Nov 2003 16:39:34 -0700, "Dmitry Streblechenko"
Post by Dmitry Streblechenko
Did you set the PR_MESSAGE_CLASS correctly (e.g. IPM.Note)?
Hell - I'm setting it to IPM.note.PROCESSED to signalize that my ece
shouldn't bother with it anymore. Just changed it back to IPM.note and
the envelope opened. Voila!

So another lesson is learned. Subclassing of the IPM.note classe results
in strange behaviour.

So I'm better advised with introducing a new property for my own
purpose. How do you suggest doing that without interfering with
properties that are already there? Is there some kind of "user
namespace" for user defined properties?

Thanks,

Volker
Dmitry Streblechenko
2003-11-17 18:32:01 UTC
Permalink
Yes, that is exactly what named propertis are for - call
IMessage::GetIDsFromNames() passing your own GUID and ids (strings or
integers), then "or" the returned tag with the correct type (PT_xxx). The
resulting tag is guaranteed to be unique in a particular message store.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Post by Volker Bartheld
Hi Dmitry!
Post by Dmitry Streblechenko
Post by Volker Bartheld
When I programmatically create a message in a folder, OL2000 shows - by
default - a *closed* envelope. This icon doesn't change even when I
doubleclick the message and browse it in an inspector.
How can I change that behaviour?
On Fri, 14 Nov 2003 16:39:34 -0700, "Dmitry Streblechenko"
Post by Dmitry Streblechenko
Did you set the PR_MESSAGE_CLASS correctly (e.g. IPM.Note)?
Hell - I'm setting it to IPM.note.PROCESSED to signalize that my ece
shouldn't bother with it anymore. Just changed it back to IPM.note and
the envelope opened. Voila!
So another lesson is learned. Subclassing of the IPM.note classe results
in strange behaviour.
So I'm better advised with introducing a new property for my own
purpose. How do you suggest doing that without interfering with
properties that are already there? Is there some kind of "user
namespace" for user defined properties?
Thanks,
Volker
Volker Bartheld
2003-11-18 12:20:50 UTC
Permalink
Hi Dmitry!

On Mon, 17 Nov 2003 11:32:01 -0700, "Dmitry Streblechenko"
Post by Dmitry Streblechenko
Yes, that is exactly what named propertis are for - call
IMessage::GetIDsFromNames() passing your own GUID and ids (strings or
integers), then "or" the returned tag with the correct type (PT_xxx). The
resulting tag is guaranteed to be unique in a particular message store.
Cool! After some research, I came up with the following code (parts are
courtesy of Microsoft):

bool char2wchar(const char* psz, WCHAR** ppwsz)
{
assert(psz);
assert(ppwsz);

WCHAR* pwsz=NULL;
int iwLen;

iwLen=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, psz, -1, NULL, 0); // calculate number of WCHARS necessary
if(!(pwsz=new WCHAR[iwLen+1])) goto err; // allocate mem
if(iwLen!=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, psz, -1, pwsz, iwLen)) goto err;
*ppwsz=pwsz; // return wide version
return true;

err:
if(pwsz) delete[] pwsz;
return false;
}

HRESULT MAPI_ProptagFromString(IMAPIProp* lpProp, const char* lpszPropName, const ULONG ulPropType, ULONG *pulPropTag)
{
HRESULT hr=NOERROR;
MAPINAMEID nameid={0};
MAPINAMEID *rgpnameid[1]={&nameid};
WCHAR* pwsz=NULL;
_SPropTagArray* lpSPropTags=NULL;

if(!char2wchar(lpszPropName, &pwsz)) // Convert property tag string to Unicode
{
hr=E_FAIL;
goto err;
}
nameid.lpguid = (GUID*)&PS_PUBLIC_STRINGS;
nameid.ulKind = MNID_STRING;
nameid.Kind.lpwstrName = pwsz;
hr=lpProp->GetIDsFromNames(1, rgpnameid, MAPI_CREATE, &lpSPropTags);
if(FAILED(hr)) goto err;

*pulPropTag = lpSPropTags->aulPropTag[0];
*pulPropTag = PROP_TAG( ulPropType, PROP_ID(*pulPropTag)); // Change PT_UNSPECIFIED to the type required by the user

err:
if(pwsz) delete[] pwsz;
MAPIFreeBuffer(lpSPropTags);
return hr;
}

Looks nice to OutlookSpy your own properties (complete with
"description") in a message! :-)

Thanks for your help!

Volker
Post by Dmitry Streblechenko
Post by Volker Bartheld
Hell - I'm setting it to IPM.note.PROCESSED to signalize that my ece
shouldn't bother with it anymore. Just changed it back to IPM.note and
the envelope opened. Voila!
So I'm better advised with introducing a new property for my own
purpose. How do you suggest doing that without interfering with
properties that are already there? Is there some kind of "user
namespace" for user defined properties?
Loading...