Obtaining the sender's address is complicated because you need to consider both Internet senders and internal Exchange senders. As I explained in "Using Collaboration Data Objects," http://www.winnetmag.com, InstantDoc ID 24392, you can retrieve an Exchange sender's SMTP address as a property of the AddressEntry object with Collaboration Data Objects (CDO). However, CDO in Outlook 2002 is subject to the same security prompts as Outlook, so you need to use Redemption to get a "safe" AddressEntry object.
Redemption includes a Fields collection that lets you access MAPI properties that provide information you can't get from Outlook object-model properties. In Listing 2, the R_GetSenderAddress() function declares two constants corresponding to the property tags that identify different MAPI properties, then obtains the values of those properties from the Fields collection. For example, the statement at callout A in Listing 2 sets the value of a string variable to the sender's address type (e.g., SMTP, EX).
Redemption adds to its SafeMailItem the Sender property, which the Outlook MailItem doesn't have. This property returns a SafeAddressEntry object, which is analogous to the AddressEntry object in CDO. Although Sender has a few useful properties of its own (e.g., Address), you might need to use its Fields collection to dig deeper into the properties. For example, at callout B in Listing 2, the R_GetSenderAddress() routine uses the Fields collection from the sender (which the objSenderAE object represents) to return the SMTP email address for the Exchange sender.
You can place the code in Listing 2 either in the ThisOutlookSession module or in a separate module and use the R_GetSenderAddress() function any time you want to get the address of a sender without displaying Outlook security prompts.
How does Microsoft feel about Redemption? I haven't seen any official opinion, but individuals at Microsoft have pointed out that it makes Outlook less secure. They're absolutely right about that. Redemption is scriptable; therefore, malicious VBScript code could use it. One way to make it more secure is to rename the Redemption.dll file to something a hacker isn't likely to guess, like r8gh36.dll. A script then would need to know the new name and use it to create Redemption objects, as in
Set objSafeMail =
CreateObject _
("r8gh36.SafeMailItem")
If you already have strong protection against viruses and find that the programming restrictions introduced with the Outlook Email Security Update are hurting your productivity, Redemption provides an easy-to-use solution.
Andrew Chester May 09, 2002