diff --git a/Global_Indexer/ClassFilehandle.vb b/Global_Indexer/ClassFilehandle.vb index 893441b..1ccb860 100644 --- a/Global_Indexer/ClassFilehandle.vb +++ b/Global_Indexer/ClassFilehandle.vb @@ -27,35 +27,57 @@ Public Class ClassFilehandle Dim oTempFilePath = pFilepath - If oTempFilePath.ToUpper.EndsWith(".MSG") Or oTempFilePath.ToUpper.EndsWith(".EML") Then - CURRENT_MESSAGEID = "" - Dim oMail As IMail = EMAIL.Load_Email(oTempFilePath) - If oMail.Attachments.Count > 0 Then - Dim oTitle As String - Dim oMessage As String + Dim oInboxRegex As New Regex("\.INBOX\d+$") - If USER_LANGUAGE = "de-DE" Then - oTitle = "Nachfrage zur Indexierung:" - oMessage = "Achtung: Die Email enthält Anhänge!" & vbNewLine & "Wollen Sie die Anhänge separat indexieren und herauslösen?" - Else - oTitle = "Question about Indexing:" - oMessage = "Attention: This Email contains Attachments!" & vbNewLine & "Do you want to extract the attachments and index them seperately?" - End If - Dim oResult As DialogResult + If oInboxRegex.IsMatch(oTempFilePath) Then + LOGGER.Info("Renaming INBOX file to EML") - ' Weird hack to force messagebox to be topmost - ' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp - oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) + Try + Dim oInfo As New FileInfo(oTempFilePath) + LOGGER.Info("Old Name: {0}", oInfo.Name) + Dim oNewName = $"{oInfo.Name}.eml" + LOGGER.Info("New Name: {0}", oNewName) + Dim oTempDirectory = IO.Path.GetTempPath() + Dim oNewPath = IO.Path.Combine(oTempDirectory, oNewName) + IO.File.Copy(oInfo.Name, oNewPath) + TEMP_FILES.Add(oNewPath) - If oResult = MsgBoxResult.Yes Then - Dim oIsFolderWatch = pHandletype.StartsWith("|FW") - Return Save_EmailAndAttachmentsToDisk(oTempFilePath, oIsFolderWatch) - End If - End If + oTempFilePath = oNewPath + Catch ex As Exception + LOGGER.Error(ex) + End Try End If - If oTempFilePath.ToUpper.EndsWith(".LNK") Then + If oTempFilePath.ToUpper.EndsWith(".MSG") Or oTempFilePath.ToUpper.EndsWith(".EML") Then + CURRENT_MESSAGEID = "" + Dim oMail As IMail = EMAIL.Load_Email(oTempFilePath) + If oMail.Attachments.Count > 0 Then + Dim oTitle As String + Dim oMessage As String + + If USER_LANGUAGE = "de-DE" Then + oTitle = "Nachfrage zur Indexierung:" + oMessage = "Achtung: Die Email enthält Anhänge!" & vbNewLine & "Wollen Sie die Anhänge separat indexieren und herauslösen?" + Else + oTitle = "Question about Indexing:" + oMessage = "Attention: This Email contains Attachments!" & vbNewLine & "Do you want to extract the attachments and index them seperately?" + End If + Dim oResult As DialogResult + + ' Weird hack to force messagebox to be topmost + ' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp + oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) + + + If oResult = MsgBoxResult.Yes Then + Dim oIsFolderWatch = pHandletype.StartsWith("|FW") + Return Save_EmailAndAttachmentsToDisk(oTempFilePath, oIsFolderWatch) + End If + End If + End If + + If oTempFilePath.ToUpper.EndsWith(".LNK") Then If USER_LANGUAGE = "de-DE" Then MsgBox("Verknüpfungen können nicht abgelegt werden!", MsgBoxStyle.Critical, "Global Indexer") Else