How to Block from sending mail to public domain.

Status
Not open for further replies.

rancho

Member
Outlook version
Outlook 2010 64 bit
Email Account
hi,

I am new to forum, please accept my greetings.

Further, my team is using business mail id to communicate. Few days back I came to know that one of them have sent confidential files to his personal IDs (Public Domain) by mistake.

Please help me to block my team from sending any mails to any available public domain.
I am using OUTLOOK 2010.
 
That is not really anything you can block in Outlook - the server usually handles it. Exchange server transport rules (including Office 365 exchange) can filter it. If you don't use exchange, you need to use your own smtp server and utility.

IRM (Individual rights management) would give you some control over the file but again, you need office 365 or an irm server.
 
Hi,
I got resolution, we can put macro into it.

Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim recipients As Outlook.recipients
Dim recip As String
Dim i
 
'this code is encoded by Rochak Mehta
 
Set recipients = Item.recipients
For i = recipients.Count To 1 Step -1
recip$ = recipients.Item(i).Address
 
On Error Resume Next
Select Case LCase(recip)
 
Case "@gmail.com", "@ymail.com", "@yahoo.com", "@yahoo.in", "@yahoo.co.in", "@rediffmail.com"
 
Item.Send
 
Case Else
Prompt$ = "You are sending this to a Public Domain. Are you sure you want to send the Mail?"
 
If MsgBox(Prompt$, vbYesNo + vbCritical + vbMsgBoxSetForeground, "Check Address: By Rochak Mehta") = vbNo Then
Cancel = True
 
End If
End Select
 
Next
End Sub
 
Hi Diane,

Thank you for the reply..

I have tried the suggestion, but its not working.
select Case instr(LCase(recip)) "Error doesn't letting me to close the last bracket".

Even my code lacking something somewhere as it prompts msg all the time whether I am sending it to a public domain(mentioned in the code) or business mail ID.

Could you please help me with this.

Thanks,
Rancho
 
This works... instead of trying to use InStr, it uses an array and compares a string containing the recipients to the domains in the array. If you add domains, you'll need to raise the count for d - or let outlook calculate it using lbound and ubound.


Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim recipients As Outlook.recipients
Dim recip As Outlook.Recipient
Dim prompt As String
Dim domain As Variant
Dim strRecip As String
Dim i
Dim d As Long
'this code is encoded by Rochak Mehta
Set recipients = Item.recipients
  For i = recipients.Count To 1 Step -1
    Set recip = recipients.Item(i) '
    strRecip = recip & ";" & strRecip
Next
Debug.Print strRecip
On Error Resume Next

domain = Array("@gmail", "@ymail", "@yahoo", "@rediffmail")

For d = 0 To 3 'LBound(domain) To UBound(domain)
Debug.Print domain(d)
If InStr(LCase(strRecip), domain(d)) Then
    prompt$ = "You are sending this to a Public Domain. Are you sure you want to send the Mail?"
If MsgBox(prompt$, vbYesNo + vbCritical + vbMsgBoxSetForeground, "Check Address: By Rochak Mehta") = vbNo Then
Cancel = True
End If
Else
Item.Send
End If
Next d

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 1
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
J How to Block junk/spam domain Using Outlook 0
E Macro to block senders domain Outlook VBA and Custom Forms 1
I Exchange 2019 - MICROSOFT-CORP-MSN-AS-BLOCK Exchange Server Administration 0
N Auto-complete - block select emails Using Outlook 3
L Block email signature image Using Outlook 1
J Object Variable or With Block Not Set Error in Outlook 2016 and not Outlook 2013 Outlook VBA and Custom Forms 3
Diane Poremsky Block Macros in Office 2013/2016 Using Outlook 0
A Block user to send emails to specific set of email ids Using Outlook 1
O Block outlook appoinments Using Outlook 1
I How to block time in another calendar without invite? Using Outlook 2
H In Exchange 2010, how to block an email containing an attachment that has foreign characters Exchange Server Administration 1
Wotme VBA to block senders Outlook VBA and Custom Forms 1
A 5.7.1 Recipient not authorized, your IP has been found on a block list Using Outlook 1
S Block read receipt when outlook is configured to Exchange server Using Outlook 0
M Change font of from/to/subject block Using Outlook 1
O Block sender option disappeared? Using Outlook 3
L Block others from inserting appointments in your calendar Using Outlook 3
M block emails with specific subjects BCM (Business Contact Manager) 1
X Highlight block of text in an outlook mail using c#2008 vsto Outlook VBA and Custom Forms 1
Q Otlk 2007 does not block when in "always prompt for..." mode Outlook VBA and Custom Forms 2
W Outlook 2021 Hanging on "Sending Emails" Using Outlook 3
Fozzie Bear Calendar Events created on iPhone have suddenly start sending invitations to attendees Using Outlook 2
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
P default font when sending email from browser Using Outlook 1
M Messages Intermittently Dont Arrive In Sent Items After Sending Successfully Using Outlook 4
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
P Sending email from outlook IMAP to GMAIL where embedded images are added as attachment Using Outlook 1
V Form data not sending for some users Outlook VBA and Custom Forms 2
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
R Microsoft Outlook 2016 - Gmail not sending, asks for password for SMTP, tried different ports Using Outlook 23
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
D Sending email from Office 365 alias in Outlook Using Outlook 3
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
L unblocking attachments before sending Office 365 Advanced Protection Using Outlook 0
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
R Warn before sending message Outlook VBA and Custom Forms 4
HarvMan Hotmail - Sending email is undeliverable Using Outlook 4
A Sending contact vcards sends older version instead of updated version Using Outlook 4
M McAllister Outlook stops Sending/Receiving/Synching after disconnecting remote desktop session Using Outlook 2
D Adding Enterprise Exchange Email Account to Outlook Prevents Sending via Outlook.com Account Using Outlook.com accounts in Outlook 10
B When sending an email, I am showing 2 of my address's Using Outlook 1
M Auto expand Distribution List Before Sending Email Outlook VBA and Custom Forms 1
A Check for words in subject header before sending email Outlook VBA and Custom Forms 4
O Run macro automatically at sending an email Using Outlook 11
W Sending To Wrong Account Using Outlook 15
H Select Specific Account When Sending Email, Based on Current Folder Outlook VBA and Custom Forms 1
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
M MsgBox when not sending from specified account Outlook VBA and Custom Forms 2

Similar threads

Back
Top