shorten subject to 100 chars when writing mail to disk, clean up, wip mail container
This commit is contained in:
@@ -12,6 +12,8 @@ Imports MailBox = Limilabs.Mail.Headers.MailBox
|
||||
'Imports DigitalData.Modules.Messaging
|
||||
|
||||
Public Class clsWorkEmail
|
||||
Private Const FILENAME_MAX_LENGTH = 100
|
||||
|
||||
Private Shared Logger As Logger
|
||||
Private MyLogger As LogConfig
|
||||
Private _DB_MSSQL As clsDatabase
|
||||
@@ -54,6 +56,9 @@ Public Class clsWorkEmail
|
||||
CURRENT_MAIL_FROM = m.Address
|
||||
Next
|
||||
|
||||
'TODO: Move all of these CURRENT_MAIL vars into a business object of type mail container
|
||||
'Dim oMail As New MailContainer(MyEmailMessage, poUID)
|
||||
|
||||
Logger.Debug($"Working on email from: {CURRENT_MAIL_FROM}...Subject: {MyEmailMessage.Subject}")
|
||||
CURRENT_MAIL_BODY_ALL = ""
|
||||
CURRENT_MAIL_BODY_ANSWER1 = ""
|
||||
@@ -327,7 +332,11 @@ Public Class clsWorkEmail
|
||||
End Try
|
||||
Next oFileName
|
||||
Dim oResult As Boolean = False
|
||||
Dim oSubjectFilename = CURRENT_MAIL_MESSAGE.Subject & ".eml"
|
||||
|
||||
' Subject can be FILENAME_MAX_LENGTH chars at most,
|
||||
' otherwise we run into errors with the path being too long
|
||||
Dim oSubjectFilename = CURRENT_MAIL_MESSAGE.Subject.Substring(0, FILENAME_MAX_LENGTH) & ".eml"
|
||||
|
||||
Logger.Debug($"oSubjectFilename (beforeclean) is: {oSubjectFilename}")
|
||||
oSubjectFilename = RemoveIllegalFileNameChars(oSubjectFilename)
|
||||
Dim oTempFilename = oTempPath & "\" & oSubjectFilename
|
||||
@@ -375,21 +384,28 @@ Public Class clsWorkEmail
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Function COPY2HDD(copy_2_hdd As Boolean, pathOriginal As String, pathemail_errors As String, messageid As Boolean) As Boolean
|
||||
Private Function COPY2HDD(pShouldCopyToDisk As Boolean, pPathOriginal As String, pPathErrors As String, pUseMessageIdAsFilename As Boolean) As Boolean
|
||||
Try
|
||||
If copy_2_hdd = True Then
|
||||
If pShouldCopyToDisk = True Then
|
||||
Logger.Debug("COPY_2_HDD is ACTIVE!")
|
||||
PATH_ERROR = pathemail_errors
|
||||
If Directory.Exists(pathOriginal) Then
|
||||
Dim oTempFilename = pathOriginal
|
||||
If messageid = True Then
|
||||
oTempFilename &= "\" & CURRENT_MAIL_MESSAGE_ID & ".eml"
|
||||
PATH_ERROR = pPathErrors
|
||||
If Directory.Exists(pPathOriginal) Then
|
||||
Dim oTempFilename = pPathOriginal
|
||||
|
||||
If pUseMessageIdAsFilename = True Then
|
||||
Dim oFileName = CURRENT_MAIL_MESSAGE_ID & ".eml"
|
||||
oTempFilename = Path.Combine(oTempFilename, oFileName)
|
||||
|
||||
'oTempFilename &= "\" & CURRENT_MAIL_MESSAGE_ID & ".eml"
|
||||
Else
|
||||
oTempFilename &= "\" & CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml"
|
||||
Dim oFileName = CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml"
|
||||
oTempFilename = Path.Combine(oTempFilename, oFileName)
|
||||
|
||||
'oTempFilename &= "\" & CURRENT_MAIL_MESSAGE.Subject.Replace(" ", "") & ".eml"
|
||||
End If
|
||||
|
||||
'Dim cleanPath As String = String.Join("", oTempFilename.Split(Path.GetInvalidPathChars()))
|
||||
If System.IO.File.Exists(oTempFilename) = False Then
|
||||
If File.Exists(oTempFilename) = False Then
|
||||
Try
|
||||
File.Delete(oTempFilename)
|
||||
Catch ex As Exception
|
||||
@@ -422,7 +438,6 @@ Public Class clsWorkEmail
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
'clsLogger.Add("Unexpected Error in COPY2HDD: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
@@ -717,17 +732,6 @@ Public Class clsWorkEmail
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function RemoveCharacter(ByVal stringToCleanUp)
|
||||
Dim characterToRemove As String = ""
|
||||
characterToRemove = Chr(34) + "#$%&'()*+,-./\~"
|
||||
Dim firstThree As Char() = characterToRemove.Take(16).ToArray()
|
||||
For index = 1 To firstThree.Length - 1
|
||||
stringToCleanUp = stringToCleanUp.ToString.Replace(firstThree(index), "")
|
||||
Next
|
||||
Return stringToCleanUp
|
||||
End Function
|
||||
|
||||
|
||||
Private Function INSERT_HISTORY_MSSQL() As Boolean
|
||||
If MessageError = False Then
|
||||
Dim ins = $"INSERT INTO TBEMLP_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_SUBJECT,EMAIL_DATE,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_FROM,PROFILE_ID) VALUES " &
|
||||
|
||||
Reference in New Issue
Block a user