सशर्त आउटलुकला प्रेषक आणि प्राप्तकर्त्याच्या पत्त्यावर आधारित ईमेल पाठविण्यापासून प्रतिबंधित करा

माझ्याकडे Outlook 2007 मध्ये एकाधिक मेल खाती सेटअप आहेत (उदा. [email protected], [email protected], इ.). अधूनमधून, सहसा स्वयं पूर्ण वैशिष्ट्याचा परिणाम म्हणून, मी चुकून [email protected] वरून ईमेल पाठवतो ज्या प्राप्तकर्त्याला फक्त [email protected] वरून मेल प्राप्त होत असावा).

(माझे निवडलेले मेल खाते) आणि प्राप्तकर्ता (प्रति किंवा CC) ईमेल पत्त्यांमधील हे निर्बंध सामान्यतः डोमेन नावाद्वारे परिभाषित केले जाऊ शकतात.

उदाहरणार्थ, [email protected] recipient-domainX.com आणि recipient-domainY.com वर पाठवू नये. आणि [email protected] recipient-domain1.com आणि recipient-domain2.com वर पाठवू नये.

त्यामुळे VBA स्क्रिप्ट किंवा मजकूर फाइलमध्ये प्रत्येक मेल खात्यासाठी हे डोमेन निर्बंध स्पष्टपणे परिभाषित करणे किंवा "हार्डकोड" करणे चांगले होईल.

तर, VBA किंवा इतर माध्यमांचा वापर करून, मी ईमेल पत्त्यांची तपासणी कशी अंमलात आणू शकतो, जर यापैकी एखाद्या निर्बंधाचे उल्लंघन होत असेल तर ईमेल पाठवण्यापासून रोखण्यासाठी.

इतर अधिक मोहक उपायांसाठी देखील उघडा.

धन्यवाद.


person splounx    schedule 08.04.2011    source स्रोत


उत्तरे (2)


हे तुम्हाला पत्त्यानुसार ईमेल स्क्रीन करू देते. मी यासाठी जास्त श्रेय मागू शकत नाही, हे मोठ्या प्रमाणावर ऑनलाइन पोस्ट केलेले अनेक भिन्न कोड एकामध्ये विलीन झाले आहेत. याची पर्वा न करता, ते ठोस कार्य करते आणि तुम्हाला जिथे व्हायचे आहे तिथपर्यंत पोहोचले पाहिजे. आमच्या कंपनीमध्ये हे सर्व बाहेरून पाठवलेले ईमेल सार्वजनिक फोल्डर HR पुनरावलोकनांमध्ये पाठवण्यासाठी वापरले जाते.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Class <> olMail Then Exit Sub
    Dim objMail As MailItem
    Set objMail = Item
    Dim NotInternal As Boolean
    NotInternal = False
    Dim objRecip As Recipient
    Dim objTo As Object
    Dim str As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next
    Const PidTagSmtpAddress As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
    Dim i As Integer
    Dim objRecipColl As Recipients
    Set objRecipColl = objMail.Recipients
    Dim objOneRecip As Recipient
    Dim objProp As PropertyAccessor
    For i = 1 To objRecipColl.Count Step 1
        Set objOneRecip = objRecipColl.Item(i)
        Set objProp = objOneRecip.PropertyAccessor
        str = objProp.GetProperty(PidTagSmtpAddress)
        If Len(str) >= 17 Then  'Len of email address screened.  
            If UCase(Right(str, 17)) <> "@COMPANYEMAIL.COM" Then NotInternal = True
        Else
            NotInternal = True
        End If
    Next
    If NotInternal = True Then
        strBcc = "[email protected]"
        Set objRecip = objMail.Recipients.Add(strBcc)
        objRecip.Type = olBCC
            If Not objRecip.Resolve Then
                strMsg = "Could not resolve the Bcc recipient. " & _
                         "Do you still want to send the message?"
                res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                        "Could Not Resolve Bcc Recipient")
                If res = vbNo Then
                    Cancel = True
                End If
            End If
    End If
    Set objRecipColl = Nothing
    Set objRecip = Nothing
    Set objOneRecip = Nothing
    Set objMail = Nothing
    Set objTo = Nothing
    Set oPA = Nothing
End Sub
person Ken    schedule 22.07.2011

मी वाचण्यास थोडासा सोपा होण्यासाठी कोड सुधारित केला आहे, प्रभावीपणे तोच कोड थोडा अधिक सुबक आहे.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.Class <> olMail Then Exit Sub

Dim sCompanyDomain As String: sCompanyDomain = "companydomain.com"

Const PidTagSmtpAddress As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"

On Error Resume Next
Dim oMail As MailItem: Set oMail = Item
Dim oRecipients As Recipients: Set oRecipients = oMail.Recipients
Dim bDisplayMsgBox As Boolean: bDisplayMsgBox = False

Dim sExternalAddresses As String
Dim oRecipient As Recipient

For Each oRecipient In oRecipients

    Dim oProperties As PropertyAccessor: Set oProperties = oRecipient.PropertyAccessor
    Dim smtpAddress As String: smtpAddress = oProperties.GetProperty(PidTagSmtpAddress)

    Debug.Print smtpAddress

    If (Len(smtpAddress) >= Len(sCompanyDomain)) Then

        If (Right(LCase(smtpAddress), Len(sCompanyDomain)) <> sCompanyDomain) Then

            ' external address found
            If (sExternalAddresses = "") Then

                sExternalAddresses = smtpAddress

            Else

                sExternalAddresses = sExternalAddresses & ", " & smtpAddress

            End If

            bDisplayMsgBox = True

        End If

    End If

Next

If (bDisplayMsgBox) Then

    Dim iAnswer As Integer
    iAnswer = MsgBox("You are about to send this email externally to " & sExternalAddresses & vbCr & vbCr & "Do you want to continue?", vbExclamation + vbYesNo, "External Email Check")

    If (iAnswer = vbNo) Then
        Cancel = True
    End If

End If

End Sub
person Abu Belal    schedule 12.07.2013