58 lines
1.8 KiB
VB.net
58 lines
1.8 KiB
VB.net
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 SubjectOriginal 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.GetShortHash(pMail.MessageID)
|
|
|
|
Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty)
|
|
SubjectOriginal = ObjectEx.NotNull(pMail.Subject, String.Empty)
|
|
|
|
SenderAddress = GetSenderAddress(pMail)
|
|
SenderDomain = GetSenderDomain(pMail)
|
|
End Sub
|
|
|
|
Private Function GetSenderAddress(pMail As IMail)
|
|
Dim oMailBox = pMail.From.FirstOrDefault()
|
|
Return oMailBox?.Address
|
|
End Function
|
|
|
|
Private Function GetSenderDomain(pMail As IMail)
|
|
Dim oMailBox = pMail.From.FirstOrDefault()
|
|
Return oMailBox.DomainPart
|
|
End Function
|
|
|
|
End Class
|