Redemption MAPIUtils.GetItemFromID returns Nothing (2)

K

Klemens Schmid

As a similar NG thread got stuck I'm asking this question again. The
following code returns Nothing in oSafeMsg. What I should mention is
that my provider is not Exchange. strEntryID looks like this:
00000000CC318A9B46C0DD47B79FDD8AB7E4619564422100. Adding the StoreID
or not doesn't matter.
The reason why I'm doing all this is that I want to create a new entry
in my Inbox looking just as if it has been sent by somebody else.
Unfortunately Redemption doesn't allow me to set the "Sent" flag on a
MessageItem object even if the item is brand new. CDO does. On the
other hand I want to set the sender in a robust way. Therefore I need
to create and assign a AddressEntry to the Sender using Redemption to
avoid the security popup.

Set oCDOSession = CreateObject("MAPI.Session")
oCDOSession.Logon showDialog:=False, newSession:=False
Set oCDOMsg = oCDOSession.Inbox.Messages.Add("Test1", "Test11",
"IPM.Note.Test1")
oCDOMsg.TimeReceived = Now
oCDOMsg.UnRead = True
oCDOMsg.Sent = True
oCDOMsg.Update
strEntryId = oCDOMsg.ID
Set oCDOMsg = Nothing
Set oSafeMsg = oMAPIUtils.GetItemFromID(strEntryId)
 
D

Dmitry Streblechenko

A couple ways:

1. (preferable) set oMAPIUtils.MAPIOBJECT to oCDOSession.MAPIOBJECT (or
Namespace.MAPIOBJECT if you are using OOM in Outlook 2002 and up). This will
force Redemption the same MAPI session
2. Use the store entry id as well as the entry id when calling
GetItemFromID:
Set oSafeMsg = oMAPIUtils.GetItemFromID(strEntryId, oCDOMsg.StoreID)


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

Klemens Schmid

Thanks Dmitry, this brought me one step further but not to the final
success. My next problem is that "Set CDOMessage.Sender =
SafeRecipient.AddressEntry" fails. Those two seem to be incompatible.
Unfortunately "Set SafeMessage.Sender = SafeRecipient.AddressEntry"
doesn't work either because Redemption's "Sender" prop is read-only.

What I finally want is to get rid of the security popup in the
following code:
'create a CDO session
Set oCDOSession = CreateObject("MAPI.Session")
oCDOSession.Logon showDialog:=False, newSession:=False
'create our message
Set oCDOMsg = oCDOSession.Inbox.Messages.Add("test", "", "IPM.Note")
'create a recient just to use it as sender
Set oRecps = oCDOMsg.Recipients
Set oRecp = oRecps.Add("Demo", "SMTP:[email protected]")
'causes a security popup:
oRecp.Resolve
'set my message props
oCDOMsg.TimeReceived = Now
oCDOMsg.UnRead = True
oCDOMsg.Sent = True
Set oCDOMsg.Sender = oRecp.AddressEntry
'get rid of the recipients
oRecps.Delete
'save everything
oCDOMsg.Update

May also be there are other ways to achieve my goal described in my
previous entry. However simply setting PR_SENDER_NAME and
PR_SENT_REPRESENTING_NAME is too weak. Also creating the item as
PostItem has some pitfalls.

My suggestions to Redemption resulting from my struggle are:
- Make Sender prop of MessageItem read/write like in CDO
- Make the Sent prop of MessageItem read/write like in CDO
- Allow to create an freestyle recipient using
MAPIUtils.CreateRecipient similar to SafeRecipients.AddEx

Best regards,
Klemens
 
D

Dmitry Streblechenko

Yep, Sender is a read-only property in Redemption. To work around this,
you'd need to set about half-dozen PR_SENDER_xxx properties, the most
important being the entry id.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top