-
Jan 21st, 2013, 12:30 PM
#1
Thread Starter
Lively Member
[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
-
Jan 22nd, 2013, 03:15 PM
#2
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
-
Jan 24th, 2013, 02:59 PM
#3
Thread Starter
Lively Member
Re: Outlook Add-In OnSend Code Not Running
Many thanks for the reply. I am still trying... very much new at the moment.
-
Jan 24th, 2013, 05:56 PM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|