none
Warning prompt before sending email to external in Outlook 2016 RRS feed

  • Question

  • Hi Dear All,

    In some Enterprise policy Outlook2016 Macro settings in Trust Center settings are "Disabled all macros without notification" by default, where macros wont run.

    I heard (Microsoft suggestion) that it is possible to use visual studio(VSTO), as an alternative way to implement it. But I don't know how to use/create it.

    My issue is Warning prompt before sending email to unknown emails does not launches.

    Does anyone can help for this issue? Thank you.

    Previous macro for outlook 2010 was as below

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

        Dim recips As Outlook.Recipients

        Dim recip As Outlook.Recipient

        Dim pa As Outlook.PropertyAccessor

        Dim prompt As String

        Dim strMsg As String

        Const PR_SMTP_ADDRESS As String = "http:sdkskldjhdskljfhlksdjd"

        Set recips = Item.Recipients

        For Each recip In recips

            If strMsg <> "" Then

            prompt = "This email will be sent outside of asdfasdfasdf to:" & vbNewLine & strMsg & "Do you want to proceed?"

            If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then

                Cancel = True

            End If

        End If

    End Sub


    • Edited by G8103V Wednesday, January 17, 2018 4:36 AM
    Wednesday, January 17, 2018 4:18 AM

All replies

  • Hello G8103V,

    For developing such an VSTO application, you need first install Visual Studio 2010 Tools for Office Runtime and then you could try to create a new VSTO project(Visual Basic->Office/SharePoint->VSTO Add-ins->Outlook XXXX VSTO Add-ins).

    You could edit the application.ItemSend event in ThisAddIn.vb.

    Here is the example.

    Public Class ThisAddIn
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
        End Sub
    
        Private Sub Application_ItemSend(Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
            Dim recips As Outlook.Recipients
            Dim recip As Outlook.Recipient
            Dim pa As Outlook.PropertyAccessor
            Dim prompt As String
            Dim strMsg As String
            Const PR_SMTP_ADDRESS As String = "http:sdkskldjhdskljfhlksdjd"
            recips = Item.Recipients
            For Each recip In recips
                'your shared code does not set value for strMsg, so the prompt won't show
                'here i set strMsg for testing, you could adjust it for your need
                strMsg = recip.Address
                If strMsg <> "" Then
                    prompt = "This email will be sent outside of asdfasdfasdf to:" & vbNewLine & strMsg & "Do you want to proceed?"
                    If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then
                        Cancel = True
                    End If
                End If
            Next recip
        End Sub
    End Class
    

    For more information developing an VSTO add-in, please try to refer to below links.

    Getting Started Programming VSTO Add-ins

    Getting Started (Office Development in Visual Studio)

    Walkthrough: Creating Your First VSTO Add-In for Outlook

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 18, 2018 3:25 AM