Still stuck at this line,
following the full code.Code:domain = Mid(strRecipientAddress, InStr(strRecipientAddress, "@"))
Code:Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim objMail As Outlook.MailItem Dim objRecipients As Outlook.Recipients Dim i As Long Dim strRecipientAddress As String Dim strPrompt As String Dim Address As String Dim domain As String If TypeOf Item Is MailItem Then Set objMail = Item Set objRecipients = objMail.Recipients For i = 1 To objRecipients.Count ' no need to step backwards as you are not removing items from the collection strRecipientAddress = objRecipients.Item(i).Address domain = Mid(strRecipientAddress, InStr(strRecipientAddress, "@")) Select Case domain Case "@my1Domain.com", "@my2Domain.com", "@my3Domain.com", "@my4Domain.com", "@my4Domain.com" Case Else: rejects = rejects & vbNewLine & strRecipientAddress End Select Next If rejects <> "" Then strPrompt = "This email will be sent outside of the company to:" & vbNewLine & strRecipientAddress & vbNewLine & "Please check recipient address." & vbNewLine & vbNewLine & "Do you still wish to send?" If MsgBox(strPrompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then Cancel = True End If End If End If End Sub




Reply With Quote
