diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj
index df58cc46..03308879 100644
--- a/GUIs.Test.TestGUI/TestGUI.vbproj
+++ b/GUIs.Test.TestGUI/TestGUI.vbproj
@@ -160,6 +160,12 @@
Form
+
+ frmEmail.vb
+
+
+ Form
+
frmFilesystem.vb
@@ -233,6 +239,9 @@
frmDocViewPure.vb
+
+ frmEmail.vb
+
frmFilesystem.vb
@@ -304,6 +313,10 @@
{903b2d7d-3b80-4be9-8713-7447b704e1b0}
Logging
+
+ {af664d85-0a4b-4bab-a2f8-83110c06553a}
+ Messaging
+
{4c86df8f-a280-40d4-85b0-10b1bf66c15c}
Windream
diff --git a/GUIs.Test.TestGUI/frmEmail.Designer.vb b/GUIs.Test.TestGUI/frmEmail.Designer.vb
new file mode 100644
index 00000000..0f60525d
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmEmail.Designer.vb
@@ -0,0 +1,234 @@
+ _
+Partial Class frmEmail
+ Inherits System.Windows.Forms.Form
+
+ 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Wird vom Windows Form-Designer benötigt.
+ Private components As System.ComponentModel.IContainer
+
+ 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
+ 'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
+ 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
+ _
+ Private Sub InitializeComponent()
+ Me.components = New System.ComponentModel.Container()
+ Me.txtUser = New System.Windows.Forms.TextBox()
+ Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
+ Me.txtPort = New System.Windows.Forms.TextBox()
+ Me.txtServer = New System.Windows.Forms.TextBox()
+ Me.txtPassword = New System.Windows.Forms.TextBox()
+ Me.Label1 = New System.Windows.Forms.Label()
+ Me.Label2 = New System.Windows.Forms.Label()
+ Me.Label3 = New System.Windows.Forms.Label()
+ Me.Label4 = New System.Windows.Forms.Label()
+ Me.Button1 = New System.Windows.Forms.Button()
+ Me.cmbSecurity = New System.Windows.Forms.ComboBox()
+ Me.Label5 = New System.Windows.Forms.Label()
+ Me.Button2 = New System.Windows.Forms.Button()
+ Me.ListBox1 = New System.Windows.Forms.ListBox()
+ Me.Button3 = New System.Windows.Forms.Button()
+ Me.txtMessageID = New System.Windows.Forms.TextBox()
+ Me.Label6 = New System.Windows.Forms.Label()
+ Me.SuspendLayout()
+ '
+ 'txtUser
+ '
+ Me.txtUser.Location = New System.Drawing.Point(12, 80)
+ Me.txtUser.Name = "txtUser"
+ Me.txtUser.Size = New System.Drawing.Size(177, 20)
+ Me.txtUser.TabIndex = 0
+ Me.txtUser.Text = "johnnie@posteo.de"
+ '
+ 'ContextMenuStrip1
+ '
+ Me.ContextMenuStrip1.Name = "ContextMenuStrip1"
+ Me.ContextMenuStrip1.Size = New System.Drawing.Size(61, 4)
+ '
+ 'txtPort
+ '
+ Me.txtPort.Location = New System.Drawing.Point(296, 35)
+ Me.txtPort.Name = "txtPort"
+ Me.txtPort.Size = New System.Drawing.Size(100, 20)
+ Me.txtPort.TabIndex = 2
+ Me.txtPort.Text = "465"
+ '
+ 'txtServer
+ '
+ Me.txtServer.Location = New System.Drawing.Point(12, 35)
+ Me.txtServer.Name = "txtServer"
+ Me.txtServer.Size = New System.Drawing.Size(278, 20)
+ Me.txtServer.TabIndex = 3
+ Me.txtServer.Text = "posteo.de"
+ '
+ 'txtPassword
+ '
+ Me.txtPassword.Location = New System.Drawing.Point(195, 80)
+ Me.txtPassword.Name = "txtPassword"
+ Me.txtPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
+ Me.txtPassword.Size = New System.Drawing.Size(201, 20)
+ Me.txtPassword.TabIndex = 5
+ '
+ 'Label1
+ '
+ Me.Label1.AutoSize = True
+ Me.Label1.Location = New System.Drawing.Point(9, 19)
+ Me.Label1.Name = "Label1"
+ Me.Label1.Size = New System.Drawing.Size(38, 13)
+ Me.Label1.TabIndex = 6
+ Me.Label1.Text = "Server"
+ '
+ 'Label2
+ '
+ Me.Label2.AutoSize = True
+ Me.Label2.Location = New System.Drawing.Point(293, 19)
+ Me.Label2.Name = "Label2"
+ Me.Label2.Size = New System.Drawing.Size(26, 13)
+ Me.Label2.TabIndex = 6
+ Me.Label2.Text = "Port"
+ '
+ 'Label3
+ '
+ Me.Label3.AutoSize = True
+ Me.Label3.Location = New System.Drawing.Point(9, 64)
+ Me.Label3.Name = "Label3"
+ Me.Label3.Size = New System.Drawing.Size(55, 13)
+ Me.Label3.TabIndex = 6
+ Me.Label3.Text = "Username"
+ '
+ 'Label4
+ '
+ Me.Label4.AutoSize = True
+ Me.Label4.Location = New System.Drawing.Point(192, 64)
+ Me.Label4.Name = "Label4"
+ Me.Label4.Size = New System.Drawing.Size(53, 13)
+ Me.Label4.TabIndex = 6
+ Me.Label4.Text = "Password"
+ '
+ 'Button1
+ '
+ Me.Button1.Location = New System.Drawing.Point(12, 154)
+ Me.Button1.Name = "Button1"
+ Me.Button1.Size = New System.Drawing.Size(75, 23)
+ Me.Button1.TabIndex = 7
+ Me.Button1.Text = "Test Login"
+ Me.Button1.UseVisualStyleBackColor = True
+ '
+ 'cmbSecurity
+ '
+ Me.cmbSecurity.FormattingEnabled = True
+ Me.cmbSecurity.Items.AddRange(New Object() {"PLAINTEXT", "SSL", "STARTTLS"})
+ Me.cmbSecurity.Location = New System.Drawing.Point(402, 34)
+ Me.cmbSecurity.Name = "cmbSecurity"
+ Me.cmbSecurity.Size = New System.Drawing.Size(121, 21)
+ Me.cmbSecurity.TabIndex = 8
+ Me.cmbSecurity.Text = "SSL"
+ '
+ 'Label5
+ '
+ Me.Label5.AutoSize = True
+ Me.Label5.Location = New System.Drawing.Point(399, 19)
+ Me.Label5.Name = "Label5"
+ Me.Label5.Size = New System.Drawing.Size(45, 13)
+ Me.Label5.TabIndex = 6
+ Me.Label5.Text = "Security"
+ '
+ 'Button2
+ '
+ Me.Button2.Location = New System.Drawing.Point(93, 154)
+ Me.Button2.Name = "Button2"
+ Me.Button2.Size = New System.Drawing.Size(107, 23)
+ Me.Button2.TabIndex = 7
+ Me.Button2.Text = "Load Messages"
+ Me.Button2.UseVisualStyleBackColor = True
+ '
+ 'ListBox1
+ '
+ Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Right
+ Me.ListBox1.FormattingEnabled = True
+ Me.ListBox1.Location = New System.Drawing.Point(541, 0)
+ Me.ListBox1.Name = "ListBox1"
+ Me.ListBox1.Size = New System.Drawing.Size(259, 450)
+ Me.ListBox1.TabIndex = 9
+ '
+ 'Button3
+ '
+ Me.Button3.Location = New System.Drawing.Point(206, 154)
+ Me.Button3.Name = "Button3"
+ Me.Button3.Size = New System.Drawing.Size(107, 23)
+ Me.Button3.TabIndex = 7
+ Me.Button3.Text = "Load Message"
+ Me.Button3.UseVisualStyleBackColor = True
+ '
+ 'txtMessageID
+ '
+ Me.txtMessageID.Location = New System.Drawing.Point(12, 128)
+ Me.txtMessageID.Name = "txtMessageID"
+ Me.txtMessageID.Size = New System.Drawing.Size(511, 20)
+ Me.txtMessageID.TabIndex = 5
+ '
+ 'Label6
+ '
+ Me.Label6.AutoSize = True
+ Me.Label6.Location = New System.Drawing.Point(9, 112)
+ Me.Label6.Name = "Label6"
+ Me.Label6.Size = New System.Drawing.Size(61, 13)
+ Me.Label6.TabIndex = 6
+ Me.Label6.Text = "MessageID"
+ '
+ 'frmEmail
+ '
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.ClientSize = New System.Drawing.Size(800, 450)
+ Me.Controls.Add(Me.ListBox1)
+ Me.Controls.Add(Me.cmbSecurity)
+ Me.Controls.Add(Me.Button3)
+ Me.Controls.Add(Me.Button2)
+ Me.Controls.Add(Me.Button1)
+ Me.Controls.Add(Me.Label5)
+ Me.Controls.Add(Me.Label2)
+ Me.Controls.Add(Me.Label6)
+ Me.Controls.Add(Me.Label4)
+ Me.Controls.Add(Me.Label3)
+ Me.Controls.Add(Me.Label1)
+ Me.Controls.Add(Me.txtMessageID)
+ Me.Controls.Add(Me.txtPassword)
+ Me.Controls.Add(Me.txtServer)
+ Me.Controls.Add(Me.txtPort)
+ Me.Controls.Add(Me.txtUser)
+ Me.Name = "frmEmail"
+ Me.Text = "frmEmail"
+ Me.ResumeLayout(False)
+ Me.PerformLayout()
+
+ End Sub
+
+ Friend WithEvents txtUser As TextBox
+ Friend WithEvents ContextMenuStrip1 As ContextMenuStrip
+ Friend WithEvents txtPort As TextBox
+ Friend WithEvents txtServer As TextBox
+ Friend WithEvents txtPassword As TextBox
+ Friend WithEvents Label1 As Label
+ Friend WithEvents Label2 As Label
+ Friend WithEvents Label3 As Label
+ Friend WithEvents Label4 As Label
+ Friend WithEvents Button1 As Button
+ Friend WithEvents cmbSecurity As ComboBox
+ Friend WithEvents Label5 As Label
+ Friend WithEvents Button2 As Button
+ Friend WithEvents ListBox1 As ListBox
+ Friend WithEvents Button3 As Button
+ Friend WithEvents txtMessageID As TextBox
+ Friend WithEvents Label6 As Label
+End Class
diff --git a/GUIs.Test.TestGUI/frmEmail.resx b/GUIs.Test.TestGUI/frmEmail.resx
new file mode 100644
index 00000000..279a4474
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmEmail.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/GUIs.Test.TestGUI/frmEmail.vb b/GUIs.Test.TestGUI/frmEmail.vb
new file mode 100644
index 00000000..fb6089a5
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmEmail.vb
@@ -0,0 +1,64 @@
+Imports DigitalData.Modules.Logging
+Imports DigitalData.Modules.Messaging
+Imports Limilabs.Mail
+
+Public Class frmEmail
+ Private Logconfig As LogConfig
+ Private Email As Email2
+
+ Private Sub frmEmail_Load(sender As Object, e As EventArgs) Handles Me.Load
+ Logconfig = New LogConfig(LogConfig.PathType.Temp)
+ Email = New Email2(Logconfig)
+ End Sub
+
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
+
+ Dim oResult = Email.Test_Login(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL)
+
+ If oResult = True Then
+ AddLog($"Connection to {txtServer.Text} successful.")
+ Else
+ AddLog($"Connection to {txtServer.Text} failed!")
+ End If
+ End Sub
+
+ Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
+ Dim oMessages = Email.Get_Messages(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL, "Inbox")
+ AddLog($"Found {oMessages.Count} Messages!")
+
+ For Each oMessage In oMessages
+ AddLog(oMessage.MessageID)
+ Next
+ End Sub
+
+ Private Sub AddLog(pMessage)
+ ListBox1.Items.Add(pMessage)
+ End Sub
+
+ Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
+ Dim oMessageId As String = txtMessageID.Text
+ Dim oMail As IMail = Email.Get_Message(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL, oMessageId, "Inbox")
+ Dim oFilename As String = IO.Path.GetTempFileName
+ oMail.Save(oFilename)
+
+ AddLog($"Mail saved to {oFilename}")
+
+ Dim oEmailTempPath = Email.Remove_AttachmentsFromEmail(oFilename)
+
+ AddLog($"Mail without attachments saved to {oEmailTempPath}")
+
+ Dim oAttachments As List(Of String) = Email.Save_AttachmentsToDisk(oFilename)
+
+ For Each oAttachment In oAttachments
+ AddLog($"Attachmen saved to {oAttachment}")
+ Next
+ End Sub
+
+ Private Sub ListBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedValueChanged
+ txtMessageID.Text = ListBox1.SelectedItem
+ End Sub
+
+ Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
+ txtMessageID.Text = ListBox1.SelectedItem
+ End Sub
+End Class
\ No newline at end of file
diff --git a/GUIs.Test.TestGUI/frmStart.Designer.vb b/GUIs.Test.TestGUI/frmStart.Designer.vb
index 1d0120b1..5906f473 100644
--- a/GUIs.Test.TestGUI/frmStart.Designer.vb
+++ b/GUIs.Test.TestGUI/frmStart.Designer.vb
@@ -29,6 +29,7 @@ Partial Class frmStart
Me.Button5 = New System.Windows.Forms.Button()
Me.Button6 = New System.Windows.Forms.Button()
Me.Button7 = New System.Windows.Forms.Button()
+ Me.Button8 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button1
@@ -94,6 +95,15 @@ Partial Class frmStart
Me.Button7.Text = "Mail"
Me.Button7.UseVisualStyleBackColor = True
'
+ 'Button8
+ '
+ Me.Button8.Location = New System.Drawing.Point(254, 73)
+ Me.Button8.Name = "Button8"
+ Me.Button8.Size = New System.Drawing.Size(236, 55)
+ Me.Button8.TabIndex = 0
+ Me.Button8.Text = "IMAP"
+ Me.Button8.UseVisualStyleBackColor = True
+ '
'frmStart
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -104,6 +114,7 @@ Partial Class frmStart
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
+ Me.Controls.Add(Me.Button8)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.Button1)
Me.Name = "frmStart"
@@ -119,4 +130,5 @@ Partial Class frmStart
Friend WithEvents Button5 As Button
Friend WithEvents Button6 As Button
Friend WithEvents Button7 As Button
+ Friend WithEvents Button8 As Button
End Class
diff --git a/GUIs.Test.TestGUI/frmStart.vb b/GUIs.Test.TestGUI/frmStart.vb
index 7fdd3c34..5fb45401 100644
--- a/GUIs.Test.TestGUI/frmStart.vb
+++ b/GUIs.Test.TestGUI/frmStart.vb
@@ -27,7 +27,7 @@ Public Class frmStart
frmDocView.Show()
End Sub
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
- frmMail.Show()
+ Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click, Button8.Click
+ frmEmail.Show()
End Sub
End Class
\ No newline at end of file
diff --git a/Modules.Messaging/Email2.vb b/Modules.Messaging/Email2.vb
new file mode 100644
index 00000000..d0245e10
--- /dev/null
+++ b/Modules.Messaging/Email2.vb
@@ -0,0 +1,241 @@
+Imports DigitalData.Modules.Logging
+Imports DigitalData.Modules.Filesystem
+Imports Limilabs.Mail
+Imports Limilabs.Client.IMAP
+Imports Limilabs.Mail.MIME
+
+Public Class Email2
+ Private ReadOnly Logger As Logger
+ Private ReadOnly LogConfig As LogConfig
+ Private ReadOnly FileEx As Filesystem.File
+
+ Public Sub New(pLogConfig As LogConfig)
+ LogConfig = pLogConfig
+ Logger = pLogConfig.GetLogger()
+ FileEx = New Filesystem.File(pLogConfig)
+ End Sub
+
+ Public Enum EmailSecurity
+ SSL
+ STARTTLS
+ End Enum
+
+ Private Function Get_PortForSecurityOption(pSecurity As EmailSecurity) As Integer
+ Select Case pSecurity
+ Case EmailSecurity.SSL
+ Return 993
+
+ Case EmailSecurity.STARTTLS
+ Return 143
+
+ Case Else
+ Return 0
+ End Select
+ End Function
+
+ Public Function Test_Login(pServer As String, pUsername As String, pPassword As String, pSecurity As EmailSecurity, Optional pFolder As String = "Inbox", Optional pPort As Integer = 0) As Boolean
+ Logger.Debug("Testing Login to Server [{0}:{1}] with user [{2}]", pServer, pPort, pUsername)
+
+ Try
+ Using oClient As New Imap()
+ Logger.Debug("Connecting to IMAP server [{0}]", pServer)
+
+ Dim oPort As Integer = pPort
+ If oPort = 0 Then
+ oPort = Get_PortForSecurityOption(pSecurity)
+ End If
+
+ If pSecurity = EmailSecurity.SSL Then
+ oClient.ConnectSSL(pServer, oPort)
+ ElseIf pSecurity = EmailSecurity.STARTTLS Then
+ oClient.Connect(pServer, oPort)
+ oClient.StartTLS()
+ Else
+ Throw New ArgumentOutOfRangeException("Security")
+ End If
+
+ Logger.Debug("Logging in with user [{0}]", pUsername)
+ oClient.UseBestLogin(pUsername, pPassword)
+
+ Logger.Debug("Fetching Inbox")
+ Dim oStatus As FolderStatus = oClient.SelectInbox()
+
+ Logger.Debug("Test finished!")
+ oClient.Close()
+ End Using
+
+ Return True
+ Catch ex As Exception
+ Logger.Warn("Login failed for server [{0}:{1}] with user [{2}]!", pServer, pPort, pUsername)
+ Logger.Error(ex)
+
+ Return False
+ End Try
+ End Function
+
+ Public Function Get_Messages(pServer As String, pUsername As String, pPassword As String, pSecurity As EmailSecurity, Optional pFolder As String = "Inbox", Optional pPort As Integer = 0) As List(Of IMail)
+ Logger.Debug("Fetching Messages from Server [{0}:{1}] with user [{2}]", pServer, pPort, pUsername)
+
+ Dim oMails As New List(Of IMail)
+
+ Try
+ Using oClient As New Imap()
+ Logger.Debug("Connecting to IMAP server [{0}]", pServer)
+
+ Dim oPort As Integer = pPort
+ If oPort = 0 Then
+ oPort = Get_PortForSecurityOption(pSecurity)
+
+ End If
+
+ If pSecurity = EmailSecurity.SSL Then
+ oClient.ConnectSSL(pServer, oPort)
+
+ ElseIf pSecurity = EmailSecurity.STARTTLS Then
+ oClient.Connect(pServer, oPort)
+ oClient.StartTLS()
+
+ Else
+ Throw New ArgumentOutOfRangeException("Security")
+
+ End If
+
+ Logger.Debug("Logging in with user [{0}]", pUsername)
+ oClient.UseBestLogin(pUsername, pPassword)
+
+ Logger.Debug("Fetching Folder [{0}]", pFolder)
+ Dim oStatus As FolderStatus = oClient.Select(pFolder)
+
+ Logger.Debug("Fetching Unseen UUIDs")
+ Dim oUUIDs As List(Of Long) = oClient.Search(Flag.Unseen)
+ Dim oMailBuilder As New MailBuilder()
+
+ Logger.Debug("Fetching Unseen Mails")
+ For Each oUUID As Long In oUUIDs
+ Dim oEmlFile As Byte() = oClient.GetMessageByUID(oUUID)
+ Dim oEmail As IMail = oMailBuilder.CreateFromEml(oEmlFile)
+ oMails.Add(oEmail)
+
+ Next
+
+ Logger.Debug("Emails fetched!")
+ oClient.Close()
+ End Using
+
+ Return oMails
+
+ Catch ex As Exception
+ Logger.Warn("Login failed for server [{0}:{1}] with user [{2}]!", pServer, pPort, pUsername)
+ Logger.Error(ex)
+ Return New List(Of IMail)
+
+ End Try
+ End Function
+
+ Public Function Get_Message(pServer As String, pUsername As String, pPassword As String, pSecurity As EmailSecurity, pMessageId As String, Optional pFolder As String = "Inbox", Optional pPort As Integer = 0) As IMail
+ Logger.Debug("Fetching Message [{0}] from Server [{1}:{2}] with user [{3}]", pMessageId, pServer, pPort, pUsername)
+
+ Dim oMail As IMail = Nothing
+
+ Try
+ Using oClient As New Imap()
+ Logger.Debug("Connecting to IMAP server [{0}]", pServer)
+
+ Dim oPort As Integer = pPort
+ If oPort = 0 Then
+ oPort = Get_PortForSecurityOption(pSecurity)
+
+ End If
+
+ If pSecurity = EmailSecurity.SSL Then
+ oClient.ConnectSSL(pServer, oPort)
+
+ ElseIf pSecurity = EmailSecurity.STARTTLS Then
+ oClient.Connect(pServer, oPort)
+ oClient.StartTLS()
+
+ Else
+ Throw New ArgumentOutOfRangeException("Security")
+
+ End If
+
+ Logger.Debug("Logging in with user [{0}]", pUsername)
+ oClient.UseBestLogin(pUsername, pPassword)
+
+ Logger.Debug("Fetching Inbox")
+ Dim oStatus As FolderStatus = oClient.Select(pFolder)
+
+ Logger.Debug("Fetching UUIDs")
+ Dim oUUIDs As List(Of Long) = oClient.Search(Flag.All)
+ Dim oMailBuilder As New MailBuilder()
+
+ Dim oInfos As List(Of MessageInfo) = oClient.GetMessageInfoByUID(oUUIDs)
+
+ Logger.Debug("Fetching Unseen Mails")
+ For Each oInfo As MessageInfo In oInfos
+ If oInfo.Envelope.MessageID = pMessageId Then
+ Dim oMailData As Byte() = oClient.GetMessageByUID(oInfo.UID)
+ oMail = oMailBuilder.CreateFromEml(oMailData)
+
+ Exit For
+ End If
+ Next
+
+ Logger.Debug("Emails fetched!")
+ oClient.Close()
+ End Using
+
+ Return oMail
+
+ Catch ex As Exception
+ Logger.Warn("Login failed for server [{0}:{1}] with user [{2}]!", pServer, pPort, pUsername)
+ Logger.Error(ex)
+ Return New List(Of IMail)
+
+ End Try
+ End Function
+
+ Public Function Remove_AttachmentsFromEmail(pFileName As String) As String
+ Try
+ Dim oTempFileName As String = IO.Path.GetTempFileName()
+ Dim oMailBuilder As New MailBuilder()
+ Dim oMail = oMailBuilder.CreateFromEmlFile(pFileName)
+
+ oMail.RemoveAttachments()
+ oMail.Save(oTempFileName)
+
+ Return oTempFileName
+ Catch ex As Exception
+ Logger.Error(ex)
+
+ Return Nothing
+ End Try
+ End Function
+
+ Public Function Save_AttachmentsToDisk(pFileName As String) As List(Of String)
+ Try
+ Dim oAttachmentPaths As New List(Of String)
+ Dim oMailBuilder As New MailBuilder()
+ Dim oMail = oMailBuilder.CreateFromEmlFile(pFileName)
+ Dim oTempPath As String = IO.Path.GetTempPath()
+
+ If oMail.Attachments.Count = 0 Then
+ Return New List(Of String)
+ End If
+
+ For Each oAttachment As MimeData In oMail.Attachments
+ Dim oPath As String = IO.Path.Combine(oTempPath, oAttachment.SafeFileName)
+ Dim oVersionedPath As String = FileEx.GetVersionedFilename(oPath)
+
+ oAttachment.Save(oVersionedPath)
+ oAttachmentPaths.Add(oVersionedPath)
+ Next
+
+ Return oAttachmentPaths
+ Catch ex As Exception
+ Logger.Error(ex)
+
+ Return New List(Of String)
+ End Try
+ End Function
+End Class
diff --git a/Modules.Messaging/Mail.vb b/Modules.Messaging/Mail.vb
deleted file mode 100644
index 11e641c1..00000000
--- a/Modules.Messaging/Mail.vb
+++ /dev/null
@@ -1,3 +0,0 @@
-Public Class Mail
-
-End Class
diff --git a/Modules.Messaging/Messaging.vbproj b/Modules.Messaging/Messaging.vbproj
index 4d4340ed..a882a73b 100644
--- a/Modules.Messaging/Messaging.vbproj
+++ b/Modules.Messaging/Messaging.vbproj
@@ -84,7 +84,7 @@
-
+
True
@@ -123,6 +123,10 @@
+
+ {991d0231-4623-496d-8bd0-9ca906029cbc}
+ Filesystem
+
{903b2d7d-3b80-4be9-8713-7447b704e1b0}
Logging