|
-
Sep 24th, 2018, 03:51 AM
#7
Re: Promt Warning List External Users, on VB Script to checks for external users
 Originally Posted by charli1
That was the suggested sollution by westconn1,
Following the full code.
Probably i missed something, could you please update it in case i missed any variable here?
vb 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 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(s, "@")) Select Case domain Case "@my1domain.com", "@my2domain.com", "@my3domain.com", "@my4domain.com", "@my5domain.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
Your Problem is in Line 14 the InStr(s, "@")
you don't assign a value to "s"
at a guess: that "s" should be strRecipientAddress
Last edited by Zvoni; Sep 24th, 2018 at 03:54 AM.
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|