PropertyChange Event Problem with "To"

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

Sue Mosher [MVP-Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top