PropertyChange Event Problem with "To"

  • Thread starter Thread starter Michael Hyatt
  • Start date Start date
M

Michael Hyatt

I am having trouble with the PropertyChange event when using the "To" field.
The problem is that the code gets fired whenever the To, CC, or BCC fields
are changed. I assume that this is because each field is somehow tied to the
Recipient collection. This code demonstrates the problem.

Sub Item_PropertyChange(ByVal Name)

Select Case Name
Case "To"
MsgBox "Item.To = " & Item.To
Case Else
MsgBox "ELSE..." & Name & " has changed"
End Select

End Sub

I want to change the value of the Item.HTMLBody based on the value in the To
field. When the user tabs out of the field, I want my code to fire. I do NOT
want it to fire when exiting the CC or BCC fields.

Can someone suggest a workaround? Thanks.
 
That's exactly the way it works. You might want to consider changing the
body only when the message is sent. Otherwise, you just have to live with
the event firing repeatedly. One good strategy is to track the To value so
you only deal with real changes:

Dim strTo

Sub Item_PropertyChange(ByVal Name)
Select Case Name
Case "To"
If Item.To <> strTo Then
MsgBox "Item.To = " & Item.To
strTo = Item.To
End If
Case Else
MsgBox "ELSE..." & Name & " has changed"
End Select

End Sub
 
Back
Top