Redemption AddressEntry Class inaccessible in C#

S

Stu Allen

I found this bit of code for VB to access the SMTP address of an
Exchange sender that I want to convert for use in C#:

Function R_GetSenderAddress(objSMail As SafeMailItem) As String
Dim strType As String
Const PR_SENDER_ADDRTYPE = &HC1E001E
Const PR_EMAIL = &H39FE001E
Dim objSAE As Redemption.AddressEntry
On Error Resume Next
strType = objSMail.Fields(PR_SENDER_ADDRTYPE)
Set objSAE = objSMail.Sender
If Not objSAE Is Nothing Then
If strType = "SMTP" Then
R_GetSenderAddress = objSAE.Address
ElseIf strType = "EX" Then
R_GetSenderAddress = objSAE.Fields(PR_EMAIL)
End If
End If
End Function

So I wrote the following:

SafeMailItem s_email = new Redemption.SafeMailItem();
s_email.Item = emails.get_Item(i); // this is in a loop of the emails
object

AddressEntry senderID = new Redemption.AddressEntryClass(); // this
line fails
string addrType = "";
addrType = (string)s_email.get_Fields(PR_SENDER_ADDRTYPE);
senderID = s_email.Sender;
if (addrType == "EX")
sender = (string)senderID.get_Fields(PrSMTPAddress);
else
sender = (string)senderID.Address;

The third line fails with:
Redemption.AddressEntryClass.AddressEntryClass()' is inaccessible due
to its protection level

So I gather its protected, but how can VB access it, assuming that
snippet I found works.
 
S

Stuart Allen

I answered my own question:

You don't need to instantiate a new class for this to work, here is the
final code:

SafeMailItem s_email = new Redemption.SafeMailItem();

s_email.Item = emails.get_Item(i); // looping on emails collection

AddressEntry senderID;

string addrType = "";

addrType = (string)s_email.get_Fields(PR_SENDER_ADDRTYPE);

senderID = s_email.Sender;

if (addrType == "EX")

sender = (string)senderID.get_Fields(PrSMTPAddress);

else

sender = (string)senderID.Address;

Enjoy.
 

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