Outlook 2003 - Intermirttant ItemSend error

Add-in Express™ Support Service
That's what is more important than anything else

Outlook 2003 - Intermirttant ItemSend error
 
Brendon Colloty


Guest


Hi,

Some of my users are getting an intermittant error when they send a new e-mail message. Unfortunatelty I have been unable to reproduce the error in my development environment - however the error message seems to indicate a problem with some of the base add-in functionality rather than the code in the routine.

The error message is as follows:-

User added an image

The ItemSend code is as follows:-

Private Sub adxOutlookEvents_ItemSend(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXOlItemSendEventArgs) Handles adxOutlookEvents.ItemSend
        Dim item As Object
        Dim mailitem As Outlook.MailItem
        If Not PromptOnSend Then Exit Sub
        Try
            GetUserSettings()
            item = e.Item

            If Not (item Is Nothing) And (item.Class = Outlook.OlObjectClass.olMail) Then
                Dim result As Integer = MessageBox(0, "Save outgoing message to Ferret?", AddInTitle & m_ProfileName, MB_YESNO + MB_ICONQUESTION + MB_APPLMODAL + MB_TOPMOST)
                Select Case result
                    Case MsgBoxResult.Yes
                        mailitem = CType(item, Outlook.MailItem)
                        SaveItemToFerret(mailitem, "C:OUT.MSG", True)
                    Case Else
                        ' Do nothing
                        ' Maybe log this in future?
                End Select
            End If

        Catch ex As Exception
            MsgBox(ex.Message & ":" & ex.StackTrace, , AddInTitle)
        Finally
            If Not (mailitem Is Nothing) Then
                Marshal.ReleaseComObject(mailitem)
            End If

            If Not (item Is Nothing) Then
                Marshal.ReleaseComObject(item)
            End If
        End Try

    End Sub


This occurs on a Windows XP Pro SP2 machine running Office 2003 SP2 and using Word as e-mail editor.
The Add-In is built with Add-In express version 2.2.1752.27346 according to the reference properties.

Note that my understanding is that the error appears before the user is prompted to "Save Item to Ferret". Ferret is a document management system that I support.

Kind Regards,

Brendon Colloty
-
Indigo Services Limited
Posted 09 Mar, 2006 16:41:26 Top
Esteban Astudillo


Guest


This may or may not be related to your problem but I understand that in general it is not a good idea to do something like this:

...
If Not (item Is Nothing) And (item.Class = Outlook.OlObjectClass.olMail) then
...

In C and C# if the first condition is False the second one is not evaluated, so this code would be safe. But in VB.Net I understand that both expressions will always be evaluated, so if "Item is Nothing" is true, then the second expression will generate an exception.

I hope the info helps
Posted 09 Mar, 2006 17:01:58 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Brendon.

Please remove the code below from the Finally block.
I think this will fix the error.

If Not (mailitem Is Nothing) Then
Marshal.ReleaseComObject(mailitem)
End If

If Not (item Is Nothing) Then
Marshal.ReleaseComObject(item)
End If
Posted 09 Mar, 2006 18:57:03 Top
Brendon Colloty


Guest


Thanks for that - I've sent the customer a new version with the changes suggested and will let you know if they still get the error.

Cheers,

Brendon.
Posted 12 Mar, 2006 22:45:37 Top