Can't cancel sending of an email from .NET AddIn - Please help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to cancel the sending of an email within my .NET AddIn once the 'Send' button is clicked. I can pick up the 'Send' click event, but the email is sent no matter what I set for the value of Cancel. Below is my code

Private Sub m_olInspectors_NewInspector(ByVal Inspector As Outlook.Inspector) Handles m_olInspectors.NewInspecto
If TypeOf Inspector.CurrentItem Is Outlook.MailItem The
'Must cast to MailItemClass due to "ambiguous name" proble
m_olMailItem = CType(Inspector.CurrentItem, Outlook.MailItemClass
End I
End Su

Private Sub m_olMailItem_Send(ByRef Cancel As Boolean) Handles m_olMailItem.ItemEvents_Event_Send
Tr
Cancel = Tru
Catch ex As Exceptio
ErrorDialog(ex.Message
End Tr
End Su

Is there something wrong with my code? I can get this to work fine in the VBA code, but it ALWAYS sends the email when I try to cancel the send from my .NET Add In

Any help is greatly appreciated.
 
Are you using a beta of Outlook? If so, that's a known problem.
http://support.microsoft.com/?id=830519

--
Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp

This posting is provided "AS IS" with no warranties, and confers no rights.



Jessica K said:
I am trying to cancel the sending of an email within my .NET AddIn once
the 'Send' button is clicked. I can pick up the 'Send' click event, but the
email is sent no matter what I set for the value of Cancel. Below is my
code:
Private Sub m_olInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector) Handles m_olInspectors.NewInspector
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
'Must cast to MailItemClass due to "ambiguous name" problem
m_olMailItem = CType(Inspector.CurrentItem, Outlook.MailItemClass)
End If
End Sub

Private Sub m_olMailItem_Send(ByRef Cancel As Boolean) Handles m_olMailItem.ItemEvents_Event_Send
Try
Cancel = True
Catch ex As Exception
ErrorDialog(ex.Message)
End Try
End Sub

Is there something wrong with my code? I can get this to work fine in the
VBA code, but it ALWAYS sends the email when I try to cancel the send from
my .NET Add In.
 
Back
Top