Outlook - Change Type of Recipient via Reflections

M

Michael

Hi,

I'm currently developing a small Programm, that should be able to create an
Outlook mail, with recipients, that are filled in from a Database.

Based on a checkbox, the recipients adresses should appear in the "To" - or
"BCC" Field. This worked well, when I just referenced the outlook library
12.0,

but part of the request is, that the programm works with all outlook
versions. So i started to rewrite my code, to use last binding.

Prior to that the code looked like this (before I started to integrate last
binding):

if (Showadresses == true)

{

oRecip.Type = (int)Outlook.OlMailRecipientType.olTo;

}

else

{

oRecip.Type = (int)Outlook.OlMailRecipientType.olBCC;

}After rewriting the code, it looks like this:

if (Showadresses == true)

{

outlookRecipient.GetType().InvokeMember("Type", BindingFlags.GetProperty,
null, outlookRecipient, new object[] { "TO" }););

}

else

{

outlookRecipient.GetType().InvokeMember("Type", BindingFlags.GetProperty,
null, outlookRecipient, new object[] { "BCC" });

}

Type is the Property, that I want to change. This is definitely wrong, but I
haven't found any examples, how to change the Type via last binding.

Does anybody know, how this works, or knows how I can find informations,
especially for my Type - Problem. Everything else works fine.

I hope everybody understands the problem. Ask, if something is not clear.



Thanks in Advance
 

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