Results 1 to 4 of 4

Thread: [RESOLVED] Outlook Add-In OnSend Code Not Running

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    98

    Resolved [RESOLVED] Outlook Add-In OnSend Code Not Running

    Hi all, I am trying to make an office add-in wich will rely on some code running when the user clicks to send the email. I've beenexperimenting for a quite awhile and cant see posts which solve the issue. but the basic issue is that the Application_ItemSend doesnt run. Any advice greatfully received.

    Code:
    Public Class ThisAddIn
        Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
            MsgBox("Hello")
        End Sub
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
        End Sub
    
    End Class

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook Add-In OnSend Code Not Running

    i am not familiar with this, but based on other applications events, the itemsend event should be in an application object module, to trap the event in a class you possibly need to declare an application variable, with events, and then set it to the application object at start up
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    98

    Re: Outlook Add-In OnSend Code Not Running

    Many thanks for the reply. I am still trying... very much new at the moment.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    98

    Re: Outlook Add-In OnSend Code Not Running

    I found this code this works properly!

    Code:
    Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
            Dim mailItem As Outlook.MailItem = TryCast(Item, Outlook.MailItem)
    
            If (mailItem IsNot Nothing) Then
                'MsgBox("Haha!!")
            End If
    
            Dim mainForm As New MyForm()
            mainForm.ShowDialog()
    
        End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width