Micheal,
Thanks for your help. What I put togehter can be found at the bottom
of this post. The one problem that I'm running into right now,
however, is that if I do the following...
- Compose a Message
- Enter a valid address in one of the address fields
- Resolve the address using Outlook's check name feature
- Remove the address and leave the address field blank
- Continue to compose the message
- Activate the Macro again
....my script then thinks that there is still a recipient even though
none appears in the TO, CC, or BCC fields. To validate this, I have
created a message box that shows these values. Am I checking the wrong
property to see if there is an addressee or is this a problem with
Outlook? I'm developing this on Outlook 2003 SP2.
Thanks!
------------------------------------------------------------------
CODE:
Public Sub Popup()
With Application.ActiveInspector
If TypeOf .CurrentItem Is Outlook.MailItem Then
'Validate that at least one recipient is
specified
If (.CurrentItem.To = "") And (.CurrentItem.CC
= "") And (.CurrentItem.BCC = "") Then
MsgBox "There must be at least one name
or distribution list in the TO, CC, or BCC box.", 48, "Error"
Else
'Resolve All Addresses
If Not
..CurrentItem.Recipients.ResolveAll Then
Set myRecipients =
..CurrentItem.Recipients
'Count Number of Recipients
Dim intCount As Integer
intCount = myRecipients.Count
'Determine Recipients that did not
resolve and echo in MsgBox
Dim strErrtxt As String
strErrtxt = "The addresses of the
following recipients could not be resolved:" & vbCrLf
For Each myRecipient In
myRecipients
If Not myRecipient.Resolved
Then
strErrtxt = strErrtxt &
vbCrLf & myRecipient.Name
End If
Next
strErrtxt = strErrtxt & vbCrLf &
vbCrLf & "Please use the ""Check Name"" feature from the Tools Menu to
validate the addresses specified."
MsgBox strErrtxt, vbExclamation,
"Error"
Else
'DEBUG: Echo that Resolve was OK
MsgBox "Resolve OK"
'
'The next few lines are commented
out to faciliate testing of the resolve functionallity
'
'.CurrentItem.Subject = "PREFIX: "
& .CurrentItem.Subject
'.CurrentItem.Send
End If
End If
'DEBUG: Display Fields
MsgBox "To: " & .CurrentItem.To & vbCrLf &
"CC: " & .CurrentItem.CC & vbCrLf & "BCC: " & .CurrentItem.BCC
End If
End With
End Sub