How to make the transport skip a recipient

G

Guest

Hi, I'm working on an addin for outlook that sends the messages to some of
the recipients by https in the Send event.
The addin is written in Delphi.
I would like the transport to skip the recipients I that have been already
processed by the client.
Removing the recipients is not good, since I want them to appear in the sent
items.
Can I acheive my goal by setting the PR_RESPONSIBILITY property to 1 for the
processed recipients in the Send event ?

Thanks,
Arcady.
 
D

Dmitry Streblechenko

"Or" the PR_RECIPIENT_TYPE with MAPI_SUBMITTED (0x80000000), e.g. MAPI_TO
(0x1) becomes 0x80000001.

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

Guest

Hi Dimitry,
Thank you for your reply.
I've tried to "or" PR_RECIPIENT_TYPE with MAPI_SUBMITTED already and it did
not worked. I saved the message after I had done the "or" and verified that
PR_RECIPIENT_TYPE was 0x80000001 after the save and after the message entered
the Outbox, but the message was delivered to the recipient nevertheless.
(I worked with Outlook2003 and Exchange 2003).

I also have tried to set PR_RESPONSIBILITY to 1, but apparently, the spooler
resets it (the message is delivered to the recipient).

Please tell me if you have any suggestions.

Thank you in advance,
Arcady.
 
D

Dmitry Streblechenko

You might want to show some of your code. Are you using MAPI alone or mix it
with OOM?

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

Guest

Before writing the actual code I have used OOM to test the method, I did "or"
on the Type property of the Recipient object, saved the message, closed it,
opened it again and checked that Type is still 0x80000001.
Isn't this test enough ?
Have you tested the "MAPI_SUBMITTED" thing ?
Btw, can outlook spy be used to test it ? I mean can it be used to change
the mapi property directly (bypassing the OOM)?

Thanks,
Arcady.
 
D

Dmitry Streblechenko

Did you look at the message with MFCMAPI or OutlookSpy to make sure the
changes were committed? If you used OOM to reopen the message, it didn't
necessarily reopened the messasge .

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

Guest

Hello,
I've checked it with outlook spy, and saw that the mapi property does equal
0x80000001 after I reopen the message.
Btw, the "submitted" recipient is not diplayed in outlook inspector's window
when I reopen the message, but the message is delivered to that recipient.
Now, I also checked that message in the inbox after it arrives, and I found
that the "submitted" recipient is duplicated (it appeares twice in that
message) and in each "instance" of it, the recipient type is 0x80000001 (in
the received message!)

Best regards,
Arcady.
 
D

Dmitry Streblechenko

Did you set the MSGFLAG_RESEND flag in PR_MESSAGE_FLAGS?

FromMSDN:

Resending an Undelivered Message
A transport provider sends a nondelivery report (NDR) when it cannot
successfully deliver a message that you have submitted. It is up to the
client whether or not users can attempt to resend these undelivered
messages. If you support resending messages, you can either use a form
provided by MAPI or implement your own. The MAPI form displays the names of
the failed recipients and the reason for the delivery failure, if possible,
and includes a button that, when selected, allows a user to resend the
message.
When a resent message is received, it should look exactly like the original
message. The recipient should be unable to differentiate between a message
that was delivered on its first attempt at transmission or a subsequent
attempt. Replies on this message should work exactly as if the message had
been sent successfully the first time.
To resend an undelivered message
Call IMAPIFolder::CreateMessage to create a new message.
Copy all of the properties from the original message, excluding
PR_MESSAGE_RECIPIENTS, the PR_SENDER properties, and the
PR_SENT_REPRESENTING properties. Make the following property modifications:
Set PR_MESSAGE_CLASS to the report's PR_ORIG_MESSAGE_CLASS property.
Set the MSGSTATUS_RESEND flag in the PR_MESSAGE_FLAGS property.
Set PR_ORIGINAL_ENTRYID to the original message's PR_ENTRYID property.
For each recipient, set MAPI_SUBMITTED in the PR_RECIPIENT_TYPE property.
Duplicate each failed recipient. Change the PR_RECIPIENT_TYPE property for
the duplicated recipient to MAPI_P1. Therefore, for each failed recipient
there are now two entries in the recipient table: one with PR_RECIPIENT_TYPE
set to its original value and the other with PR_RECIPIENT_TYPE set to
MAPI_P1.
Call ScCreateConversationIndex to set up conversation tracking if desired.
Call the new message's IMessage::ModifyRecipients method to update the
recipient list.
Call IMessage::SubmitMessage to save and send the new message.

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

Guest

Hello Dimitry,
Thanks for the advice.

I have managed to make a resend message such that it is not delivered to the
recipients marked by MAPI_SUBMITTED.
Now I have another difficulty: MSDN says that for the recipients to whom I
would like to deliver the resent message, I need to "duplicate" them and to
set their type to "MAPI_P1".

MSDN:
"Duplicate each failed recipient. Change the PR_RECIPIENT_TYPE property for
the duplicated recipient to MAPI_P1."

I don't know how to do that "duplicate" properly.
I have tried to do it as follows:
1. I allocate an ADRLIST
2. For each failed recipient I allocate an ADRENTRY in that list.
3. For each failed recipient I copy the properties of the original recipient
into an entry in the list. (I copy all the properties excluding PR_ROWID)
4. I call ModifyRecipients with MODRECIP_ADD and the list I've built.

I get a MAPI_E_INVALID_PARAMETER error.

What am I doing wrong ?
How to "duplicate" the recipients properly ?

Thanks a lot,
Arcady.
 
G

Guest

Hello Dimitry,
Thanks for the advice.

I have managed to make a resend message such that it is not delivered to the
recipients marked by MAPI_SUBMITTED.
Now I have another difficulty: MSDN says that for the recipients to whom I
would like to deliver the resent message, I need to "duplicate" them and to
set their type to "MAPI_P1".

MSDN:
"Duplicate each failed recipient. Change the PR_RECIPIENT_TYPE property for
the duplicated recipient to MAPI_P1."

I don't know how to do that "duplicate" properly.
I have tried to do it as follows:
1. I allocate an ADRLIST
2. For each failed recipient I allocate an ADRENTRY in that list.
3. For each failed recipient I copy the properties of the original recipient
into an entry in the list. (I copy all the properties excluding PR_ROWID)
4. I call ModifyRecipients with MODRECIP_ADD and the list I've built.

I get a MAPI_E_INVALID_PARAMETER error.

What am I doing wrong ?
How to "duplicate" the recipients properly ?

Thanks a lot,
Arcady.
 
D

Dmitry Streblechenko

When adding recipients you need to make sure you do not have the PR_ROWID
property.
Youy should be able to just change the prop type from PT_LONG to PT_ERROR -
ModifyRecipients() is supposed to ignore such properties.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Joined
Oct 18, 2011
Messages
1
Reaction score
0
Dear Arcady,

I am in a similar situation as yours. i.e. I need to skip recipients while sending an email.

Have you got around the problems you were having? Could you please let me know.

Thanks
Pradeep
 

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