none
Outlook crashes sometimes on drag and drop to vb.net application RRS feed

  • Question

  • Hi,

    i am using a VB app to save Mails from Outlook 2016 per drag and drop to filesystem. This app is working for a couple of mails (sometimes only 2 or 3 sometimes 50 or more), but after a while Outlook crashes and I get the following message in the event Log.

    Name der fehlerhaften Anwendung: OUTLOOK.EXE, Version: 16.0.8827.2179, Zeitstempel: 0x5a628888

    Name des fehlerhaften Moduls: ntdll.dll, Version: 10.0.16299.192, Zeitstempel: 0x16e7ff7f

    Ausnahmecode: 0xc0000005

    Fehleroffset: 0x0002cfd6

    ID des fehlerhaften Prozesses: 0x5ff4

    Startzeit der fehlerhaften Anwendung: 0x01d39e72ed36be6f

    Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE

    Pfad des fehlerhaften Moduls: C:\WINDOWS\SYSTEM32\ntdll.dll

    Berichtskennung: 6a6e60f4-8749-4a1b-af2a-4fd4a1b25178

    Vollständiger Name des fehlerhaften Pakets:

    Anwendungs-ID, die relativ zum fehlerhaften Paket ist:

    The code is quite simple, I have a form with a label on it where I drop the mails.

    Option Strict On

     

    Imports System.IO

    Imports System.Linq

    Imports System.Runtime.InteropServices

    Imports Outlook = Microsoft.Office.Interop.Outlook

     

    Public Class Form1

     

        Private ReadOnly outlookApplication As New Outlook.Application

        Private crashCount As Integer = 0

     

        Private Sub Label1_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles Label1.DragOver

            If e.Data.GetDataPresent("FileGroupDescriptor") Then

                e.Effect = DragDropEffects.Copy

            Else

                e.Effect = DragDropEffects.None

            End If

        End Sub

        Private Sub Label1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles Label1.DragDrop

            Try

                If e.Data.GetDataPresent("FileGroupDescriptor") Then

                    'supports a drop of a Outlook message

                    For Each objMi As Outlook.MailItem In outlookApplication.ActiveExplorer.Selection()

                        crashCount = crashCount + 1

                        'hardcode a destination path for testing

                        Dim strFile As String = Path.Combine("c:\temp", FixFileName(objMi.Subject + ".msg"))

                        lstResults.Items.Add(crashCount & " : " & strFile)

                        objMi.SaveAs(strFile)

                    Next

                End If

     

            Catch ex As System.Exception

                lstResults.Items.Add("An error occured in the drop event")

                lstResults.Items.Add(ex.ToString)

            End Try

        End Sub

        Private Function FixFileName(ByVal pFileName As String) As String

            Dim invalidChars As Char() = Path.GetInvalidFileNameChars()

            If (pFileName.IndexOfAny(invalidChars) >= 0) Then

                pFileName = invalidChars.Aggregate(pFileName, Function(current, invalidChar) current.Replace(invalidChar, Convert.ToChar("_")))

            End If

            Return pFileName

        End Function

     

    End Class

     

    I tried my app on some computers but always the same - after a while Outlook is crashing.
    Windows 10 Pro 1709 (16299.192) 64 Bit
    Office Professional Plus 2016 Version 1712 (Build 8827.2179 Click and Run) 32 Bit

    (Some of the computer have older build version from Windows and Office)

    What could be the reason?

    Thanks,

    Monday, February 5, 2018 1:07 PM

All replies

  • Hello MarkusGr1,

    I tried to test your code. I saved about 30 mails and keep running the project for 15 minute. Every thing work well for me. It seem that my translator is not enough smart so I failed to get much information from the error message. Could you give us a English error message or tell us your office language.

    Besides, the latest version for Outlook is 9001.2138 and I would suggest you update to last version for testing too.

    Best Regards

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 6, 2018 11:11 AM
  • Hello Terry,

    thank you very much for your efforts and your help. I have updated to the latest version, unfortunately that did not help. My office language is German (Deutsch). Time does not seem to be the problem I can reproduce the error in minutes. If I move mails from different mailboxes (eg Inbox, Drafts, send Items) the error occurs faster and more often.

    I have an IMAP account, on customer side there is an exchange serve. Of course, the real project is a bit more complicated and  Outlook crashes more often.
    I tested it with office 2013, there are no problems.

    thanks

    Markus

    Tuesday, February 6, 2018 4:35 PM
  • Hi MarkusGr,

    To check whether it is related with Outlook, I suggest you start Outlook in safe mode, then run your project, will it crash?

    To check whether it is related with your VB App, I suggest you create a new winform with code below:

        Private Function FixFileName(ByVal pFileName As String) As String
    
            Dim invalidChars As Char() = Path.GetInvalidFileNameChars()
    
            If (pFileName.IndexOfAny(invalidChars) >= 0) Then
    
                pFileName = invalidChars.Aggregate(pFileName, Function(current, invalidChar) current.Replace(invalidChar, Convert.ToChar("_")))
    
            End If
    
            Return pFileName
    
        End Function
        Private outlookApplication As New Outlook.Application
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            For Each objMi As Outlook.MailItem In outlookApplication.ActiveExplorer.Selection()
                Dim strFile As String = Path.Combine("D:\temp", FixFileName(objMi.Subject + ".msg"))
                objMi.SaveAs(strFile)
            Next
        End Sub
    

    Will the Outlook Crash after you select mailItem and click button?

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 8, 2018 8:58 AM
  • Hello MarkusGr1,

    According to your error message, it seems that this error is caused by the ntdll.dll error.

    Please check the solution in below thread could work for you.

    how to fix ntdll.dll error

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 8, 2018 9:04 AM