Add Language Module, use RemoveInvalidCharacters to Remove Emojis from Filenames

This commit is contained in:
Jonathan Jenne
2021-07-08 13:50:05 +02:00
parent 79202e379e
commit 917d8b71a0
4 changed files with 56 additions and 56 deletions

View File

@@ -53,7 +53,7 @@ Public Class ClassFileDrop
Loop
stmInput.Close()
'Sonderzeichen entfernen
Dim Tempfilename = ClassFilehandle.InvalidCharacters(stbFileName.ToString)
Dim Tempfilename = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(stbFileName.ToString)
Dim anhaenge = e.Data.GetDataPresent("FileContents")
'Dim path As String = "C:\VBProjekte\Dateien"
'// put the zip file into the temp directory
@@ -93,61 +93,68 @@ Public Class ClassFileDrop
End If
End If
If e.Data.GetDataPresent("FileGroupDescriptor") Then
Dim oApp As Outlook.Application
Dim oApp As Outlook.Application
Try
oApp = New Outlook.Application()
Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Unexpected error in Initialisieren von Outlook-API:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & "Evtl ist Outlook nicht in der dafür vorgesehenen For")
Return False
End Try
LOGGER.Info(" Drop of msg")
'supports a drop of a Outlook message
Dim myobj As Outlook.MailItem
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
myobj = oApp.ActiveExplorer.Selection.Item(i)
Dim subj As String = myobj.Subject
If subj = "" Then
subj = "NO_SUBJECT"
End If
If subj.Contains("\") Then
subj = subj.Replace("\", "-")
End If
If subj.Contains("/") Then
subj = subj.Replace("/", "-")
End If
'Sonderzeichen entfernen
subj = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(subj)
'hardcode a destination path for testing
Dim oFilename As String = IO.Path.Combine(Path.GetTempPath, subj + ".msg")
oFilename = oFilename.Replace("?", "")
oFilename = oFilename.Replace("!", "")
oFilename = oFilename.Replace("%", "")
oFilename = oFilename.Replace("$", "")
LOGGER.Info("Drop of msg - File:" & oFilename)
Try
oApp = New Outlook.Application()
myobj.SaveAs(oFilename)
Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Unexpected error in Initialisieren von Outlook-API:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & "Evtl ist Outlook nicht in der dafür vorgesehenen For")
Return False
End Try
LOGGER.Info(" Drop of msg")
'supports a drop of a Outlook message
Dim myobj As Outlook.MailItem
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
myobj = oApp.ActiveExplorer.Selection.Item(i)
Dim subj As String = myobj.Subject
If subj = "" Then
subj = "NO_SUBJECT"
End If
If subj.Contains("\") Then
subj = subj.Replace("\", "-")
End If
If subj.Contains("/") Then
subj = subj.Replace("/", "-")
End If
'Sonderzeichen entfernen
subj = ClassFilehandle.InvalidCharacters(subj)
'hardcode a destination path for testing
Dim oFilename As String = IO.Path.Combine(Path.GetTempPath, subj + ".msg")
oFilename = oFilename.Replace("?", "")
oFilename = oFilename.Replace("!", "")
oFilename = oFilename.Replace("%", "")
oFilename = oFilename.Replace("$", "")
LOGGER.Info("Drop of msg - File:" & oFilename)
Try
myobj.SaveAs(oFilename)
Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Die Email konnte aufgrund einer Sicherheitseinstellung im Outlook nicht abgelegt werden! " &
MsgBox("Die Email konnte aufgrund einer Sicherheitseinstellung im Outlook nicht abgelegt werden! " &
"Bitte wenden Sie sich an Ihren Administrator, " &
"um den programmatischen Zugriff auf Outlook zuzulassen. " &
"Weitere Informationen finden Sie im Log.", MsgBoxStyle.Critical, "Global Indexer")
End Try
End Try
ReDim Preserve files_dropped(i)
files_dropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
Next
Return True
ReDim Preserve files_dropped(i)
files_dropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
Next
Return True
'Drop eines Outlook Attachments
End If
Catch ex As Exception
MsgBox("Error in Drop-File" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
'Private Sub DragDrop_HandleTobit(e As DragEventArgs)
' If e.Data.GetDataPresent("#TobitMsgData") Then
' Dim Quellpfad As String = ""