Rename Projects, clean up interfaces
This commit is contained in:
64
App/EmailProfiler.Common/MailContainer.vb
Normal file
64
App/EmailProfiler.Common/MailContainer.vb
Normal file
@@ -0,0 +1,64 @@
|
||||
Imports Limilabs.Mail
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Public Class MailContainer
|
||||
Private Const SUBJECT_MAX_LENGTH = 25
|
||||
|
||||
''' <summary>
|
||||
''' The Mail object created by Limilabs
|
||||
''' </summary>
|
||||
Public ReadOnly Property Mail As IMail
|
||||
''' <summary>
|
||||
''' The IMAP Id coming from the IMAP folder. Used to reference the mail.
|
||||
''' </summary>
|
||||
Public ReadOnly Property ImapId As Integer
|
||||
''' <summary>
|
||||
''' The original MessageID from the eml file
|
||||
''' </summary>
|
||||
Public ReadOnly Property MessageIdOriginal As String
|
||||
''' <summary>
|
||||
''' The new MessageID, which is generated by hashing the original MessageID
|
||||
''' </summary>
|
||||
Public ReadOnly Property MessageId As String
|
||||
''' <summary>
|
||||
''' The subject, truncated to SUBJECT_MAX_LENGTH characters
|
||||
''' </summary>
|
||||
Public ReadOnly Property Subject As String
|
||||
|
||||
Public ReadOnly Property SenderDomain As String
|
||||
Public ReadOnly Property SenderAddress As String
|
||||
|
||||
|
||||
Public Sub New(pMail As IMail, pImapId As Integer)
|
||||
Mail = pMail
|
||||
ImapId = pImapId
|
||||
|
||||
MessageIdOriginal = pMail.MessageID
|
||||
MessageId = StringEx.GetHash(pMail.MessageID)
|
||||
|
||||
Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty)
|
||||
|
||||
SenderAddress = GetSenderAddress(pMail)
|
||||
SenderDomain = GetSenderDomain(pMail)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function GetSenderAddress(pMail As IMail)
|
||||
Dim oMailBox = pMail.From.FirstOrDefault()
|
||||
If oMailBox Is Nothing Then
|
||||
Return "InvalidSenderAddress"
|
||||
Else
|
||||
Return oMailBox.Address
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function GetSenderDomain(pMail As IMail)
|
||||
Dim oMailBox = pMail.From.FirstOrDefault()
|
||||
If oMailBox Is Nothing Then
|
||||
Return "InvalidSenderAddress"
|
||||
Else
|
||||
Return oMailBox.DomainPart
|
||||
End If
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user