MS ClientSuite1

This commit is contained in:
Digital Data - Marlon Schreiber
2018-12-21 10:14:12 +01:00
parent 2e076ad41b
commit 5df3b96e0a
25 changed files with 3165 additions and 7 deletions

View File

@@ -11,6 +11,76 @@ Public Class Email
_logger = LogConfig.GetLogger()
_logConfig = LogConfig
End Sub
Public Function IMAP_COLLECT(INBOXNAME As String, MYMAIL_SERVER As String, MYMAIL_PORT As Integer, MYMAIL_USER As String, MYMAIL_USER_PW As String) Returns
Try
_logger.Info(String.Format("Working on IMAP_COLLECT..."))
Dim client As New ImapClient(MYMAIL_SERVER, MYMAIL_PORT)
'If LOG_ERRORS_ONLY = False Then
' Dim emaillogger As New Independentsoft.Email.Logger(My.Application.Info.DirectoryPath & "\Log\IDSoftMailLog.txt")
' AddHandler emaillogger.WriteLog, AddressOf OnWriteLog
'client.Logger = emaillogger
'End If
client.ValidateRemoteCertificate = False
client.Connect()
client.Login(MYMAIL_USER, MYMAIL_USER_PW)
client.SelectFolder("Inbox")
Dim envelopes As Envelope() = client.ListMessages()
For i As Integer = 0 To envelopes.Length - 1
If Not IsNothing(envelopes(i).Subject) Then
'If envelopes(i).Subject.ToString.ToUpper.Contains("[PROCESSMANAGER]") Or envelopes(i).Subject.ToString.ToUpper.Contains("[ADDI]") Then
_logger.Info($"Working on email: UniqueID: {envelopes(i).UniqueID} - Subject:{envelopes(i).Subject} - Date {envelopes(i).Date.ToString}")
Dim message As Mime.Message = client.GetMessage(envelopes(i).UniqueID)
If Not IsNothing(message) Then
MAIL_LIST.Add(message)
End If
'End If
End If
Next
client.Disconnect()
_logger.Debug("IMAP_COLLECT finished!")
Return True
Catch ex As Exception
_logger.Error(ex, "Unexpected Error in IMAP COLLECT:")
Return False
End Try
End Function
Public Function TEST_IMAP_COLLECT(INBOXNAME As String, MYMAIL_SERVER As String, MYMAIL_PORT As Integer, MYMAIL_USER As String, MYMAIL_USER_PW As String)
Try
Logger.Info(String.Format("Working on TEST_IMAP_COLLECT....."))
Dim client As New ImapClient(MYMAIL_SERVER, MYMAIL_PORT)
'If LOG_ERRORS_ONLY = False Then
' Dim emaillogger As New Independentsoft.Email.Logger(My.Application.Info.DirectoryPath & "\Log\IDSoftMailLog.txt")
' AddHandler emaillogger.WriteLog, AddressOf OnWriteLog
'client.Logger = emaillogger
'End If
client.Connect()
client.Login(MYMAIL_USER, MYMAIL_USER_PW)
client.SelectFolder(INBOXNAME)
Dim envelopes As Envelope() = client.ListMessages()
For i As Integer = 0 To envelopes.Length - 1
If Not IsNothing(envelopes(i).Subject) Then
'If envelopes(i).Subject.ToString.ToUpper.Contains("[PROCESSMANAGER]") Or envelopes(i).Subject.ToString.ToUpper.Contains("[ADDI]") Then
MsgBox($"Working on email: UniqueID: {envelopes(i).UniqueID} - Subject:{envelopes(i).Subject} - Date {envelopes(i).Date.ToString}")
Dim message As Mime.Message = client.GetMessage(envelopes(i).UniqueID)
End If
Next
client.Disconnect()
Logger.Info("TEST_IMAP_COLLECT finished!")
Return True
Catch ex As Exception
Logger.Error(ex, "Unexpected Error in TEST_IMAP_COLLECT:")
Return False
End Try
End Function
Public Function NewEmail(mailto As String, mailSubject As String, mailBody As String,
mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attment As String = "")
@@ -38,8 +108,10 @@ Public Class Email
oTextBodyPart.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable
Dim formattedBody = "<font face=""Tahoma"">" & mailBody & "<br><br>>> Service: " & SENDER_INSTANCE & "<br>" &
">> DateTime: " & My.Computer.Clock.LocalTime.ToShortDateString & " " &
My.Computer.Clock.LocalTime.ToLongTimeString & "</font>"
">> DateTime: " & My.Computer.Clock.LocalTime.ToShortDateString.ToString("dd.MM.yyyy") & " " &
My.Computer.Clock.LocalTime.ToLongTimeString.ToString("H:mm:ss") & "</font>"
Dim thisDate1 As Date = #6/10/2011#
Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + ".")
oTextBodyPart.Body = formattedBody
oMessage.BodyParts.Add(oTextBodyPart)
If attment <> String.Empty Then
@@ -125,7 +197,7 @@ Public Class Email
_logger.Info("Message to " & oMailempfaenger & " has been send.")
oError = False
Catch ex As Exception
_logger.Warn("clsEmail.Client.Send: " & ex.Message)
_logger.Warn("NewEmail.Send: " & ex.Message)
oError = True
oEmailCient.Disconnect()
Continue For