Cancelling mail item send is having problem

  • Thread starter Thread starter Dhananjay
  • Start date Start date
D

Dhananjay

Hi all,
I am developing my Com-addin (Shared Addin) in VB2005 for Office XP.
I have created just a single application object in general section. &
in OnConnection method I am assigning that application object to my
application object. It is working perfectly. Now, in ItemSend event of
my application object I have just written statement "Cancel = True" to
cancel the send event of mailitem. But then also my item is sent every
time. Important fact is that if I developed the same addin in VB 6 it
cancels out that send event. So please can any body tell me the
solution?
My whole code is as follows -

imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Outlook

<GuidAttribute("26DFECA2-E40B-4B80-8CEB-CA869330D6E5"),
ProgIdAttribute("MyAddin1.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim WithEvents myOut As Application

Public Sub OnBeginShutdown(ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnStartupComplete
End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnDisconnection
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal
connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As
Object, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnConnection
myOut = application
If myOut IsNot Nothing Then MsgBox("connected")
End Sub

Private Sub myOut_ItemSend(ByVal Item As Object, ByRef Cancel As
Boolean) Handles myOut.ItemSend
Cancel = True
End Sub
End Class


This is just the code I am having in my Connect class. Then also my
item is sent every time I send the mailitem. This works perfectly if I
create vb6 project.

Please reply me as soon as possible.

Thanks
 
Hi Ken!
Can you do one favor for me.
All the code from the link is in VC / C#. I am not C guy. Can you just
give me example for VB.net. I am taking your valuable time, but the
link you specified is the solution for me.

Thanks in advance.
 
I don't have an example using VB.NET and I certainly don't have the time to
translate that C# code into VB.NET, sorry.
 
Back
Top