MS
This commit is contained in:
@@ -19,13 +19,12 @@ Public Class Limilab
|
||||
Private User As String
|
||||
Private Password As String
|
||||
Private AuthType As String
|
||||
Private LimilabImapObject As Imap
|
||||
Public CurrentImapObject As Imap
|
||||
Public ErrorMessage As String
|
||||
Private CURR_ListUIDs As List(Of Long)
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
LogConfig = LogConfig
|
||||
Logger = LogConfig.GetLogger()
|
||||
Logger.Info("Limilab initialized")
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' Initializes the module.
|
||||
@@ -50,7 +49,10 @@ Public Class Limilab
|
||||
If Initialized = False Then
|
||||
Return True
|
||||
Else
|
||||
LimilabImapObject.Close()
|
||||
If Not IsNothing(CurrentImapObject) Then
|
||||
CurrentImapObject.Close()
|
||||
End If
|
||||
|
||||
Return True
|
||||
End If
|
||||
|
||||
@@ -81,7 +83,7 @@ Public Class Limilab
|
||||
Logger.Debug("Connecting...")
|
||||
Dim oReturn As Boolean = ImapConnect()
|
||||
If oReturn = True Then
|
||||
LimilabImapObject.Close()
|
||||
CurrentImapObject.Close()
|
||||
End If
|
||||
Return oReturn
|
||||
Catch ex As Exception
|
||||
@@ -110,6 +112,26 @@ Public Class Limilab
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Function IMAPGetMessageIDs_AllMails() As List(Of Long)
|
||||
Dim oListuids As New List(Of Long)
|
||||
Logger.Debug("Starting IMAPGetMessageIDs ...")
|
||||
If Initialized = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
Try
|
||||
Dim oConnect As Boolean = ImapConnect()
|
||||
|
||||
If oConnect = True Then
|
||||
oListuids = ImapGetMessageIDs_All()
|
||||
CURR_ListUIDs = oListuids
|
||||
End If
|
||||
Return oListuids
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
ErrorMessage = ex.Message
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Private Function ImapConnect() As Boolean
|
||||
Try
|
||||
If Initialized = False Then
|
||||
@@ -153,7 +175,7 @@ Public Class Limilab
|
||||
Logger.Debug("Login with User and password...")
|
||||
oReturnImap.UseBestLogin(User, Password)
|
||||
Logger.Debug(">> Logged on!")
|
||||
LimilabImapObject = oReturnImap
|
||||
CurrentImapObject = oReturnImap
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -186,9 +208,24 @@ Public Class Limilab
|
||||
Private Function ImapGetMessageIDs_Unseen() As List(Of Long)
|
||||
Dim oListuids As New List(Of Long)
|
||||
Try
|
||||
LimilabImapObject.SelectInbox()
|
||||
CurrentImapObject.SelectInbox()
|
||||
|
||||
oListuids = LimilabImapObject.Search(Flag.Unseen)
|
||||
oListuids = CurrentImapObject.Search(Flag.Unseen)
|
||||
|
||||
Return oListuids
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
ErrorMessage = ex.Message
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Private Function ImapGetMessageIDs_All() As List(Of Long)
|
||||
Dim oListuids As New List(Of Long)
|
||||
Try
|
||||
CurrentImapObject.SelectInbox()
|
||||
|
||||
oListuids = CurrentImapObject.Search(Flag.All)
|
||||
|
||||
Return oListuids
|
||||
Catch ex As Exception
|
||||
@@ -302,7 +339,7 @@ Public Class Limilab
|
||||
End Function
|
||||
Public Function GetMailInfo(UID As Long) As Boolean
|
||||
Try
|
||||
Dim eml = LimilabImapObject.GetMessageByUID(UID)
|
||||
Dim eml = CurrentImapObject.GetMessageByUID(UID)
|
||||
Dim email As IMail = New MailBuilder().CreateFromEml(eml)
|
||||
' Subject
|
||||
Console.WriteLine(email.Subject)
|
||||
@@ -336,7 +373,7 @@ Public Class Limilab
|
||||
Try
|
||||
Dim WORKMAIL_LIST As New ArrayList()
|
||||
For Each oUID In CURR_ListUIDs
|
||||
Dim oEml = LimilabImapObject.GetMessageByUID(oUID)
|
||||
Dim oEml = CurrentImapObject.GetMessageByUID(oUID)
|
||||
Dim oEmail As IMail = New MailBuilder().CreateFromEml(oEml)
|
||||
WORKMAIL_LIST.Add(oEmail)
|
||||
Next
|
||||
@@ -348,10 +385,15 @@ Public Class Limilab
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Public Function IMAP_DeleteByUID(UID As String) As Boolean
|
||||
Public Function IMAP_DeleteByUID(UID As Long) As Boolean
|
||||
Try
|
||||
LimilabImapObject.DeleteMessageByUID(UID)
|
||||
Return True
|
||||
If Not IsNothing(CurrentImapObject) Then
|
||||
CurrentImapObject.DeleteMessageByUID(UID)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
ErrorMessage = ex.Message
|
||||
|
||||
Reference in New Issue
Block a user