Hi guys,
A while ago, somebody wrote a little VBA utility to help us to log CRM events. Whenever a user sends an email to a customer, it logs the fact in our CRM database. This is the programmatic process:
1. Grab the email address from ActiveInspector.CurrentItem.To
2. If it's a valid email address, all well and good. Proceed to Step 8.
3. If not a valid email address (it must be a friendly name, perhaps located in Exchange), look for the address in:
ActiveInspector.CurrentItem.Recipients.Item(1).AddressEntry.GetExchangeUser.PrimarySmtpAddress
4. If it's a valid email address, all well and good. Proceed to Step 8.
5. If not a valid email address (it must be in the user's Contact list), look for the address in:
ActiveInspector.CurrentItem.Recipients.Item(1).AddressEntry.GetContact.Email1Address
6. If it's a valid email address, all well and good. Proceed to Step 8.
7. If not a valid email address, then crash!!! <<------------------------------------------------- Here's where I'm stuck!
8. Get the CustomerID from the CRM, based on email address.
9. Do a bunch of other stuff (for example, send the email, and log the event in the CRM).
I'm a former Access MVP, and am highly experienced with VBA, but my forte is clearly not Outlook. What I'd like to do is find the email address by looking in the local cache, and make sure I get the actual email address rather than the friendly name. I'm not sure if 'local cache' is the right word; I know Outlook stores frequently used email address in some sort of cache, even if the user has not explicitly stored it as a Contact. I just don't know how to find it. Can anyone point me in the right direction, maybe with a method name?
Also, while mucking about with it, I found the following. Would it be useful in this scenario?
ActiveInspector.CurrentItem.Recipients.Item(1).AddressEntry.GetExchangeDistributionList
Many thanks,
Graham R