Use of SafeRecipients

J

Jonatan

Hi all,

I have started to use Redemption today and I am getting a problem that
is quite likely to be my fault!!

I just want to display the AddressBook select recipients and send the
email. For some reason the safeMailItem recipients list does not get
updated and the program fails with error 0x80004005.

I suppose that I do not need to loop through the returned list of
recipients and populate the recipients list of the SafeMailItem!!!

My code is the following


Outlook.MailItem mailItem = (Outlook.MailItem)
this.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

Redemption.SafeMailItem sMailItem = new
Redemption.SafeMailItem();

mailItem.Subject = "Hello";

sMailItem.Item = mailItem;

Redemption.MAPIUtils mapiUtils = new
Redemption.MAPIUtils();
Redemption.SafeRecipients recipients =
sMailItem.Recipients;

recipients = (Redemption.SafeRecipients)
mapiUtils.AddressBook(recipients, "Select Name", false, true, 3, "To",
"Cc", "Bcc", 0);

//This method displays 1 if I selected one recipient
MessageBox.Show("" + recipients.Count);

// This one displays always 0
MessageBox.Show("" + sMailItem.Recipients.Count);

// As a result when I send the item it fails because
there are no recipients
sMailItem.Send();

Thank you for your help

Jonatan
 
J

Jonatan

Hi all,

I realised that the recipients object returned by the AddressBook is a
copy so I need to update the Recipients from the SafeMailItem.

How can I do that without going though one by one?
 
S

Sue Mosher [MVP-Outlook]

You will need to iterate the SafeRecipients collection. It would be the same if you were using CDO and Session.AddressBook.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

You need to get the Recipients collection of the SafeMailItem as
SafeRecipients, and then one by one add the returned recipients to that
SafeRecipients collection, using the Add or AddEx methods of the
SafeRecipients collection.
 
Top