Messaging: Add SMTP Functions, inital tests

This commit is contained in:
Jonathan Jenne
2021-07-26 16:32:06 +02:00
parent 999e2e617b
commit 0f0b517c56
2 changed files with 237 additions and 119 deletions

View File

@@ -7,28 +7,34 @@ Public Class frmEmail
Private Email As Email2
Private Sub frmEmail_Load(sender As Object, e As EventArgs) Handles Me.Load
Logconfig = New LogConfig(LogConfig.PathType.Temp)
Logconfig = New LogConfig(LogConfig.PathType.Temp, ProductName:="TestGUI.IMAP")
Logconfig.Debug = True
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.SSLTLS)
Using oClient = Email.New_IMAPConnection(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL)
Dim oResult = Email.Test_IMAPLogin(oClient, "Inbox")
If oResult = True Then
AddLog($"Connection to {txtServer.Text} successful.")
Else
AddLog($"Connection to {txtServer.Text} failed!")
End If
If oResult = True Then
AddLog($"Connection to {txtServer.Text} successful.")
Else
AddLog($"Connection to {txtServer.Text} failed!")
End If
End Using
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.SSLTLS, "Inbox")
AddLog($"Found {oMessages.Count} Messages!")
For Each oMessage In oMessages
AddLog(oMessage.MessageID)
Next
Using oClient = Email.New_IMAPConnection(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL)
Dim oMessages = Email.Get_IMAPMessages(oClient, "Inbox")
AddLog($"Found {oMessages.Count} Messages!")
For Each oMessage In oMessages
AddLog(oMessage.MessageID)
Next
End Using
End Sub
Private Sub AddLog(pMessage)
@@ -36,22 +42,24 @@ Public Class frmEmail
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.SSLTLS, oMessageId, "Inbox")
Dim oFilename As String = IO.Path.GetTempFileName
oMail.Save(oFilename)
Using oClient = Email.New_IMAPConnection(txtServer.Text, txtUser.Text, txtPassword.Text, Email2.EmailSecurity.SSL)
Dim oMessageId As String = txtMessageID.Text
Dim oMail As IMail = Email.Get_IMAPMessage(oClient, oMessageId, "Inbox")
Dim oFilename As String = IO.Path.GetTempFileName
oMail.Save(oFilename)
AddLog($"Mail saved to {oFilename}")
AddLog($"Mail saved to {oFilename}")
Dim oEmailTempPath = Email.Remove_AttachmentsFromEmail(oFilename)
Dim oEmailTempPath = Email.Remove_AttachmentsFromEmail(oFilename)
AddLog($"Mail without attachments saved to {oEmailTempPath}")
AddLog($"Mail without attachments saved to {oEmailTempPath}")
Dim oAttachments As List(Of String) = Email.Save_AttachmentsToDisk(oFilename)
Dim oAttachments As List(Of String) = Email.Save_AttachmentsToDisk(oFilename)
For Each oAttachment In oAttachments
AddLog($"Attachmen saved to {oAttachment}")
Next
For Each oAttachment In oAttachments
AddLog($"Attachmen saved to {oAttachment}")
Next
End Using
End Sub
Private Sub ListBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedValueChanged