View Single Post
  #3  
Old April 19th 06, 07:49 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Need to verify TO recipient

You're on the right track, but the key point that you've missed is that there is no Recipient field. Think about it: An item can have multiple recipients. So, you need to check each one:

Function Item_Send()
Dim blnOKToSend
blnOKToSend = False
For Each recip in Item.Recipients
If recip.Address = " Then
blnOKToSend = True
Exit For
End If
Next
Item_Send = blnOKToSend
End Function

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

" wrote in message ...
Hello All,

When the user hits send on a custom mail item I have created, I want to make
sure a specific email address is in the To recipient line. How can I do
this? I have tried the code below, but I do not think I am even on the right
track.

Function Item_Send()
dim txt,pos
Set txt = Item.Recipient.Value
'A textual comparison starting at position 4
pos = InStr(txt,"Riley, Jeff",1)
If pos = 0 Then
Item.Recipient.Value = "Riley, Jeff (MVC)" & txt
End If
End Function

Thank you,
Jeff Riley

Ads