Using Redemption to add recipients in a custom form in Outlook

M

morten_belsvik

Hello,

I have a custom form in Outlook 2000 which is started from a simple
addin written in C#. Before showing the form I want to add a
recipient. The problem is that the added recipient is not displayed in
the "To" field of the custom form. Here is the code:

Outlook._NameSpace olNS = applicationObject.GetNamespace("MAPI");

olNS.Logon("", "", false, false);
Outlook.MAPIFolder oInbox =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

if (oInbox == null)
{
olNS = null;
return;
}

// Add new message using my custom form
Outlook.MailItem oMailItem =
(Outlook.MailItem)oInbox.Items.Add("IPM.Note.MyForm");

if (oMailItem != null)
{
// Use Redemption to avoid security warning when adding recipient
Redemption.SafeMailItem oSafeMailItem = new
Redemption.SafeMailItem();
if (oSafeMailItem != null)
{
oSafeMailItem.Item = oMailItem;
Redemption.SafeRecipient oSafeRecipient =
oSafeMailItem.Recipients.Add("(e-mail address removed)");

oSafeRecipient.Resolve(false);

oMailItem.Display(false);
oSafeMailItem = null;
}
oMailItem = null;
}
olNS.Logoff();
olNS = null;


When using Outlook Spy I can see that the recipient is added, but it
does not show up in the "To" field. If I do not use Redemption, the
recipient is shown, but then I get the security warning. Also if I use
the standard mail form (IPM.Note) instead of my own, it works fine with
Redemption. To ensure that there is nothing wrong with my custom form
I have created a form from the standard mail form and just published it
with the IPM.Note.MyForm classname.

Any ideas?

Thanks,
Morten
 
S

Sue Mosher [MVP-Outlook]

If you're adding recipients whose names/addresses you know will all resolve,
there is no need to use Redemption. Simply set the value of the MailItem.To
property to the names/addresses, in a semi-colon delimited list.
 
M

morten_belsvik

Thanks for your help Sue. That works fine.

Unfortunately I also have to read the content in the "To" field
when the user presses a "Store Default Values" button in the custom
form. The value shall be stored and used as default when a new
message is created (that's the way the customer wants it). Reading
"MailItem.To" causes the Security warning to be shown. The
Redemption object contains no data in "To" and "Recipients".
Do you know if this is a known problem with Redemption or am I using it
the wrong way?

Morten
 
M

morten_belsvik

Here is an example from the script in the form:

Dim oSafeMsg ' As Redemption.SafeMailItem

' Create safe mail item, connect to original object
Set oSafeMsg = CreateObject("Redemption.SafeMailItem")
oSafeMsg.Item = Item

MsgBox "Recipients in safe object: " & oSafeMsg.Recipients.Count & " ("
&
oSafeMsg.To & ")"
MsgBox "Recipients in original object: " & Item.Recipients.Count & " ("
&
Item.To & ")"

The first messsage show is "Recipients in safe object: 0 ()".
The second message shown is "Recipients in original object: 1
(TestAlias)"

I discovered that if I perform Item.Save before running this code it
works fine. Guess that means that I finaly got the point. Redemption
use Extended MAPI and the message need to be stored before Extended
MAPI and threefore Redemption can handle the message?

Morten
 

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