开发者

Outlook 2003 mail window freezes on click of Send button

I've developed an Outlook 2003 addin with VSTO + VS 2008.

There is a VB 6 application which creates an instance of Outlook mail, attaches a document to it and shows this to user to send.

When user clicks "send" button the mail window freezes. It happens on production machines only.

The VB6 code is as follows:

Private Sub Command1_Click()

Dim objOlApp As New Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim objAttachments As Attachments
Dim arrFilesToAttach(1) As String

    Set objOlApp = New Outlook.Application
    Set objMailItem = objOlApp.CreateItem(olMailItem)
    Set objAttachments = objMailItem.Attachments

    arrFilesToAttach(0) = Text1.Text

    For l = 0 To 0
        strTemp = arrFilesToAttach(l)
        If strTemp <> "" Then
            objAttachments.Add arrFilesToAttach(l)
        End If
    Next

    objMailItem.Display True

    Set objOlApp = Nothing
    Set objMailItem = Nothing
    Set objAttachments = Nothing
End Sub

To see if it's my addin is creating an issue. I created a simple outlook addin and added some File IO code to the startup event Inside try...catch block. I disabled previous addin and installed this new sample addin.

The result was surprising, the sample addin too, was creating the problem. It changes the LoadBehaviour in registry to 2 for the sample addin. The try...catch block is not catching the exception. I've added an handler for Appdomain's unhandledException, but that too, is not getting fired.

Please help...开发者_如何转开发 Thanks in Advance.


If outlook is changing the loadbehaviour to 2 for your addin, that usually means that something about that addin is faulting during the load, and outlook is disabling it.

there's all +kinds+ of reasons an addin could fault on load, (missing referenced dlls, rights, etc etc) so that's one issue.

To identify whether your addin is hanging up the send process, just disable you're addin (for instance set loadbehavior to 0). Not really any need to create a sample addin for that.

If things work right with your addin disabled, but fail with it enabled, there's very likely something wrong in the addin.

At that point, what I do is start "releasing" chunks of code.

What I mean is I start commenting out entry points (or comment all entry points out and uncomment just one at a time).

For instance, if you've got stuff happening in the Startup event, comment it out, recompile and test. If no failure, remove the comment, and comment something else higher up the chain.

I also tend to use a lot of logging (usually with Log4Net, but you can use anything really).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜