Results 1 to 2 of 2

Thread: How to run a code after attachment file is fully opened on outlook itself?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Post How to run a code after attachment file is fully opened on outlook itself?

    I need to run a code after I open attachment on outlook itself (either opened manually or by vba).
    I tried to use AttachmentRead event ,
    But I found out this event is triggered just after I double click on the attached file or using open from context menu (the attachment still not opened).
    my need,to run a code after the attachment is fully opened by it's relative application.
    In advance,grateful for all useful comments and answers.

    Option Explicit
    Option Compare Text
    Public WithEvents MyItem As Outlook.MailItem
    Private Sub Application_ItemLoad(ByVal Item As Object)
        If Item.Class = olMail Then
            Set MyItem = Item
        End If
    End Sub
    Private Sub MyItem_AttachmentRead(ByVal Attachment As Attachment)
         MsgBox ("This is a test message") 'This is a test code
    End Sub

  2. #2
    The best you can do is to track the MailItem.BeforeAttachmentWriteToTempFile event - but it is triggered both by opening and by previewing the attachment, and you won't know the file name unless you monitor the temp folder where Outlook creates the files.
    Your best bet is to work with the application that actually opens the file.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts