To all:
I’m trying to trap the Send event in Outlook to make sure the email address is valid before sending. Basically, we have a situation where email addresses from InterAction have a wrong email address format, so I decided to write some code (below) in Outlook’s Send event to correct it.
OK, testing for and correcting a bad email address is no big deal. What I’m having a problem with is writing the corrected email address back to the Recipients(n).Address property. The Microsoft documentation says the Address property is read/write, but every time I run the code, I get an error message saying that the Address property is read-only!
What am I doing wrong here? Is this because I shouldn’t even be using the Send event to try to do this, because the email has actually been sent off and it’s already too late to change the bad email address?
Thanks for your help,
Stephan
‘****************************************** BEGIN CODE ******************************************
Option Explicit
‘ ————————————————————————
‘ Purpose: Traps the Item_Send event so that invalid email addresses in
‘ the format (name ) from InterAction get changed.
‘
‘ Inputs: None
‘
‘ Written: 10/26/01 by Stephan Ip
‘ ————————————————————————
Function Item_Send()
Dim n
Dim strEmailAddr
Dim lngBeginBracket, lngEndBracket
‘ loop through all the recipients
For n = 1 To Item.Recipients.Count
strEmailAddr = Item.Recipients(n).Address
lngBeginBracket = InStr(1, strEmailAddr, “”)
‘ test to see if email address has beginning and end brackets,
‘ which means it’s an invalid email address
If lngBeginBracket 0 And lngEndBracket 0 Then
‘ parse email address to strip it of the brackets
strEmailAddr = Mid(strEmailAddr, lngBeginBracket + 1, _
lngEndBracket – (lngBeginBracket + 1))
End If
‘ change email address to corrected parsed address
Item.Recipients(n).Address = strEmailAddr ‘*** MS OUTLOOK VB HELP SAYS ADDRESS PROPERTY IS READ/WRITE
‘*** WHY DO I GET A MESSAGE SAYING IT’S READ-ONLY WHEN RUN???
Next
End Function