none
How to Disable Received/Sent Emails in “Edit” Mode Automatically with Outlook VBA RRS feed

  • Question

  • Hi Team, 

    Below is the Code which I am using, however it's allowing me to insert a new attachment (using edit email Option ) in the last email which I received in my inbox. Still trying to find out how can I rectify this issue. OR how can we disable 

    Can you please help me with that

    Public WithEvents myItem As Outlook.MailItem
    Dim flag As Boolean

    Private Sub Application_ItemLoad(ByVal Item As Object)

    If Item.Class = olMail Then
            flag = False
            Set myItem = Item
        End If
    End Sub

    Private Sub myItem_AttachmentRead(ByVal Attachment As Attachment)
    flag = True
    End Sub

    Private Sub myItem_Write(Cancel As Boolean)
    If flag Then
    MsgBox "You are not allowed to save "
    Cancel = True
    myItem.Close olDiscard
    End If
    End Sub
    Public Sub Initalize_Handler()
    Const strCancelEvent = "Application-defined or object-defined error"
    Set myItem = Application.ActiveInspector.CurrentItem
    End Sub

    Private Sub myItem_AttachmentAdd(ByVal Attachment As Attachment)
    flag = False ' if I select true then it will not allow me to insert Document while replying or sending any new email. 
    End Sub

    Private Sub myItem_AttachmentRemove(ByVal Attachment As Attachment)
    flag = True
    End Sub

    Thursday, July 12, 2018 2:07 AM

Answers

All replies