P
Philippe W.
Hi,
I am trying to develop a very simple macro that warn the
user when he/she is sending a message outside his/her
company.
The following code is triggered on Application_ItemSend:
Dim rec As Recipient
Dim badRecStr As String
Dim shouldWarn As Boolean
Dim i As MailItem
Dim objMsg As Object
badRecStr = ""
shouldWarn = False
For Each rec In Item.Recipients
If StrComp(Right(rec.Address, 6), "hp.com",
vbTextCompare) <> 0 Then
badRecStr = badRecStr & Chr(10) & " " &
rec.Address
shouldWarn = True
End If
Next rec
If shouldWarn = True Then
If MsgBox("You are about to send a message
OUTSIDE hp:" & _
badRecStr & "." & Chr(10) & Chr(10) & "Are you
sure you are willing to do so?", _
vbYesNo + vbSystemModal +
vbExclamation, "Outside hp message warning") = vbNo _
Then
Cancel = True
Exit Sub
End If
End If
End Sub ' Application_ItemSend
It turns out that the address field does not contain
necessary the smtp address, but some X400 / X500 ones
(the behavior depends on whether I am connected or not,
whether the address has been resolved using the local
contact list or the server one...)
Does someone know a way to get the SMTP address ?
Thanks a lot,
Philippe W.
I am trying to develop a very simple macro that warn the
user when he/she is sending a message outside his/her
company.
The following code is triggered on Application_ItemSend:
Dim rec As Recipient
Dim badRecStr As String
Dim shouldWarn As Boolean
Dim i As MailItem
Dim objMsg As Object
badRecStr = ""
shouldWarn = False
For Each rec In Item.Recipients
If StrComp(Right(rec.Address, 6), "hp.com",
vbTextCompare) <> 0 Then
badRecStr = badRecStr & Chr(10) & " " &
rec.Address
shouldWarn = True
End If
Next rec
If shouldWarn = True Then
If MsgBox("You are about to send a message
OUTSIDE hp:" & _
badRecStr & "." & Chr(10) & Chr(10) & "Are you
sure you are willing to do so?", _
vbYesNo + vbSystemModal +
vbExclamation, "Outside hp message warning") = vbNo _
Then
Cancel = True
Exit Sub
End If
End If
End Sub ' Application_ItemSend
It turns out that the address field does not contain
necessary the smtp address, but some X400 / X500 ones
(the behavior depends on whether I am connected or not,
whether the address has been resolved using the local
contact list or the server one...)
Does someone know a way to get the SMTP address ?
Thanks a lot,
Philippe W.