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.
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.