You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This could be achieved through a toggle button on the ribbon which would execute this code if checked:
Private Sub mailCheck_Send(item As Object, Cancel As Boolean)
'Purpose: if recipients cover more than one domain, confirm before sending
'Reason for existence: Warn user before sending if email is addressed to more than one client, probably accidentally
Dim part As Variant
Dim confirm As Boolean
Dim recs As String
Dim prompt As String
Dim domain As String
Dim r As Recipient
Dim myNewMail As MailItem
On Error GoTo oops
Set myNewMail = item
If myNewMail Is Nothing Then Exit Sub
confirm = False
recs = ""
'determine domains of recipients
For Each r In myNewMail.Recipients
Debug.Print r.Name; ","; r.Address
part = Split(r.Address, "@", 2)
If UBound(part) > 0 Then 'external address
domain = part(1)
If Not domain Like "*.gt.com" Then
'compare domains
If recs <> "" And InStr(recs, domain) = 0 Then confirm = True
recs = recs & ", " & domain
End If
Else 'internal address, do nothing
End If
Next
'prepare msg prompt
prompt = "Are you sure you want to send this message?"
If confirm Then
recs = Mid(recs, 2)
prompt = Replace(prompt, "?", " to outside domains: " & recs & "?")
End If
'ask user. Comment "if" statement if you want to ask all the time
If confirm Then
If MsgBox(prompt, vbYesNo + vbQuestion + vbDefaultButton2, "SEND CONFIRMATION") = vbNo Then
Cancel = True
End If
End If
Exit Sub
oops:
MsgBox Err & " " & Err.Description, vbCritical
Set myNewMail = Nothing
End Sub
The text was updated successfully, but these errors were encountered:
This could be achieved through a toggle button on the ribbon which would execute this code if checked:
The text was updated successfully, but these errors were encountered: