Imports Limilabs.Mail Imports DigitalData.Modules.Base Public Class MailContainer Private Const SUBJECT_MAX_LENGTH = 25 ''' ''' The Mail object created by Limilabs ''' Public ReadOnly Property Mail As IMail ''' ''' The IMAP Id coming from the IMAP folder. Used to reference the mail. ''' Public ReadOnly Property ImapId As Integer ''' ''' The original MessageID from the eml file ''' Public ReadOnly Property MessageIdOriginal As String ''' ''' The new MessageID, which is generated by hashing the original MessageID ''' Public ReadOnly Property MessageId As String ''' ''' The subject, truncated to SUBJECT_MAX_LENGTH characters ''' 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