Re: Setting Global Object ID for Appointments

Tech-Archive recommends: Fix windows errors by optimizing your registry



How exactly doyou populate the corresponding SPropValue structure? Do you
set SPropValue.Value.b to 0/1 or some other value (such as 0xFFFFFFFF)?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrcote@xxxxxxxxx> wrote in message
news:803fbaa6-f146-4d4a-9bf1-c98c2d4d64b3@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Aha, okay, that worked for the global object ID, but I still can't set
property 0x8229. No errors are generated this time, but the value
obstinately refuses to change to true. I've confirmed that it is
getting the proper tag. I'm calling CHANGE_PROP_TYPE() on the tag
with the argument PT_BOOLEAN, I've allocated the memory for an
LPSPropValue, and assigned a value of 1 to the LPSPropValue's
Value.bin. What else could I be missing?

Mark

On Jan 19, 5:26 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx> wrote:
After taking out the calls to IMessage::SaveChanges, you need to set the
MAPI properties, reset the Subject, *then* call AppointmentItem.Save.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:545228ce-d457-4176-be1a-77887bf9d520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In this case we're creating an appointment, and I call
_AppointmentItem::Save(), then I execute the code I posted, after
calling _AppointmentItem::get_MAPIOBJECT() on the same
_AppointmentItem (which is okay, right? I assume _AppointmentItem
stays valid once I call Save()--it seems to be valid for setting the
global object ID afterwards).

As for not calling SaveChanges(), I can't get this to work. I've had
no problems calling SaveChanges() on the IMessages so far, but not
calling it results in the new global object ID not sticking. I tried
taking out the SaveChanges() call and instead resetting the subject
with this, but to no avail:

// Force a save.
BSTR subject;
hr = _item->get_Subject(&subject);
if (SUCCEEDED(hr))
{
_bstr_t blank("");
BSTR blanktmp = blank.copy();
_item->put_Subject(blanktmp);
_item->put_Subject(subject);

}

Also, I imagine I should also call IMessage::Release() if I obtain an
LPMESSAGE from IMAPIFolder::OpenEntry(), correct?

I will try some of your recommendations vis-a-vis the invites-sent
flag soon.

By the way, many thanks for all your help. I am incredibly grateful;
people like you keep my faith in humanity alive and well! :)

Mark

On Jan 17, 5:53 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx> wrote:

Did you previously call SaveChanges(0)? Firstly, use KEEP_OPEN_READWRITE
instead of 0. Secondly, you are not supposed to call
IMessage::SaveChanges
if you retrieved IMessage from the MAPIOBJECT property. Saving the
chnages
is Outlook's prerogative, even if sometime you need to convince Outlook
that
something has changed; resetting teh Subject property woudl do.
Thirdly, yes, you need to release IMessage retrieved from the MAPIOBJECT
property.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:8f3f9105-be7e-4877-b11f-2bafc5c08cd6@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yup, setting type to PT_BOOLEAN. I'm getting the IMessage via
_AppointmentItem::get_MAPIOBJECT(). This works for setting the global
object ID but not for this particular value. A related question: if I
use get_MAPIOBJECT(), do I have to call IMessage::Release() when I'm
finished getting/setting properties?

Here's my code, very similar to my previous excerpt:

LOG4CXX_INFO(logger, "setting invites-sent flag");
HRESULT hr = S_OK;
LPSPropTagArray lpNamedPropTag = NULL;
GetPropTag(lpMsg, lpNamedPropTag, (LPGUID) &PSETID_Appointment,
LID_INVITES_SENT);

ULONG propTag = lpNamedPropTag->aulPropTag[0];
MAPIFreeBuffer(lpNamedPropTag);

LPSPropValue lpPropVal;
MAPIAllocateBuffer(sizeof(SPropValue), (LPVOID *)&lpPropVal);
lpPropVal->Value.b = invitesSent;

lpPropVal->ulPropTag = propTag;
lpPropVal->ulPropTag = CHANGE_PROP_TYPE(lpPropVal->ulPropTag,
PT_BOOLEAN);

// this call fails with E_ACCESSDENIED
lpMsg->SetProps(1, lpPropVal, NULL);

if (SUCCEEDED(hr))
{
hr = lpMsg->SaveChanges(0);

}

MAPIFreeBuffer(lpPropVal);

The function GetPropTag is as follows:

HRESULT GetPropTag(LPMESSAGE lpMsg, LPSPropTagArray &lpNamedPropTag,
LPGUID guid, LONG id)
{
HRESULT hr = S_OK;

MAPINAMEID NamedID = {0};
LPMAPINAMEID lpNamedID = NULL;

// Set up the request to GetIDsFromNames.
NamedID.lpguid = guid;
NamedID.ulKind = MNID_ID;
NamedID.Kind.lID = id;
lpNamedID = &NamedID;

// Find the prop tag
hr = lpMsg->GetIDsFromNames(1, &lpNamedID, NULL, &lpNamedPropTag);

return hr;

}

Mark

On Jan 15, 6:32 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx> wrote:

Did you set the right type (PT_BOOLEAN)?
How do you open IMessage?

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:1ef3df80-9fba-4630-86a5-49f4ad0586c7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Aha, well I'm glad to have contributed another discovery vis-a-vis
the
length and data fields!

Quick question: there's a property I'm trying to set (IID 0x8229--
appears to represent whether or not invites have been sent), but I
get
an E_ACCESS_DENIED error (0x80070005). I've read that some MAPI
values are read-only, so I'm not too surprised. However, I was able
to change the value in Outlook Spy. What is Outlook Spy doing that
allows it to write to such a property?

Mark

On Jan 14, 6:19 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx>
wrote:
Oh, wait! I thought you meant task ids.
Appointment ids were hacked some time ago and the results were
posted
in
this newsgroups: if I remember correctly, the varying field is 8
bytes
long
and is the FILETIME when the appointment is created - see the last
message
in the following
thread:http://groups.google.com/group/microsoft.public.win32.programmer.mess...

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:5167ae96-ffee-4099-b69c-574f4c53b4ff@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

More discoveries! I am no longer sure about the middle bytes
have
to
be a set pattern... I just saw a global object ID which was all
0s
from byte 17 to byte 36, inclusive. My test values may not have
worked because of other values, like bytes 37-40, which I just
figured
out actually indicate the length of the remaining data, which is
why
I
was only able to set 56-byte values earlier--I was leaving the
0x10
alone, meaning only 16 bytes could follow.

So my current working hypothesis for the best way to set this
value
is
the 16-byte prefix 04 00 00 00 82 00 E0 00 74 C5 B7 10 1A 82 E0
08,
followed by 20 0-bytes, followed by a 4-byte length indicator
(such
as
10 00 00 00 for 16), followed by that many arbitrary bytes. This
is
perfect for my needs.

Mark

On Jan 12, 6:35 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx>
wrote:
What happens if you set the value id to one of the existing ids?
I am just curious if the contenst of your new id have anything
to
do
wit
hthis.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:8b7273a0-5137-4c77-8cff-dc389b391293@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Aha! That was it. I didn't realize I would have to call
CHANGE_PROP_TYPE() again, since I had called it when I
originally
got
the tag. I have now verified that, after setting the 0x23 and
0x3
properties on a meeting request that has no recipients, they
are
retained after I add recipients, while the entry ID changes.

Unfortunately I got a new, completely different problems. I'm
not
sure exactly what is happening, and I'm still investigating,
but
Outlook is unable to send out any messages after a recipient
is
added
to a meeting request that formerly had no recipients. The
original
mail fails to send as do any updates; I get the following
error:

Task 'pop.gmail.com - Sending' reported error (0x800CCC13)
:
'Unable to connect to the network. Check your network
connection
or
modem.'

My network connection is fine, and this only occurs after that
exact
series of steps. Adding recipients while creating a meeting
request
does not trigger this error. I have done some cursory
research
on
this error, and it happens to a lot of people who have
perfectly
fine
network connections. It is somehow related to my setting the
global
IDs. Very strange. Any ideas?

Mark

On Jan 10, 5:50 pm, "Dmitry Streblechenko"
<dmi...@xxxxxxxxxxx>
wrote:
Do you set the property type (PT_BINARY) after calling
GetIDsFromNames?

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Cote" <mrc...@xxxxxxxxx> wrote in message

news:08ca5088-33c7-4bee-8b98-c87fefe478d8@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Jan 10, 4:55 pm, "Dmitry Streblechenko"
<dmi...@xxxxxxxxxxx>
wrote:
Firstly, you might want to post in teh OUtlook specific
newsgroups
(e.g.
developer.outlook.addins) or, event better, a MAPI
specific
newsgroup
(win32.programmer.messaging)
Secondly, how do you retrieve the value of
lpNamedPropTag->aulPropTag[0]?
What does SetProps() returns?

Sure, I'll post there as well. Only posted here originally
because
of
a couple posts back in 2005 that were exactly about this
but
with
no

...

read more »


.


Quantcast