问题描述
我目前正在使用 mailkit 和 visual basic 构建一个基本的电子邮件客户端。我已经能够在收件箱中获取电子邮件,但现在我希望能够在 Web 视图 2 中显示 HTML 电子邮件。mailkit 的所有文档都是用 C# 编写的,虽然我理解其中的大部分内容,但我不知道不知道如何正确地将其转换为可视化基本代码。这些是我一直在使用的链接: https://github.com/jstedfast/MailKit/blob/master/Documentation/Examples/ImapExamples.cs https://github.com/jstedfast/MailKit https://github.com/jstedfast/MimeKit/blob/master/samples/MessageReader/MessageReader/MessageViewWindow.cs
这是我写的:
Imports System
Imports MimeKit
Imports MailKit
Imports MailKit.Net.Imap
Imports MailKit.Security
Imports MailKit.Search
Imports System.Threading
Public Class ReceiveEmails
Dim HasAttachment As Boolean = False
Dim aryAttachments() As String
Private Sub btnConnect_Click(sender As Object,e As EventArgs) Handles btnConnect.Click
'Dim connectThread As New Thread(AddressOf Login)
'connectThread.Start()
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub btnBack_Click(sender As Object,e As EventArgs) Handles btnBack.Click
Me.Hide()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object,e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'normally a thread or background worker cannot update the UI,but the line below is a cheap way to accomplish this task
'not the ideal way to update the UI apparently,but it works
CheckForIllegalCrossthreadCalls = False
Dim username As String = txtAccount.Text.ToString
Dim password As String = txtPassword.Text
Dim imapServerName As String = cmbServer.SelectedItem
Dim imapServer As New ImapClient(New ProtocolLogger("imap.log"))
Dim i As Integer = 0
imapServer.Connect(imapServerName,993,SecureSocketoptions.SslOnConnect)
imapServer.Authenticate(username,password)
imapServer.InBox.Open(FolderAccess.ReadOnly)
Dim emailMessage = imapServer.InBox.GetMessage(i)
For count As Integer = 0 To imapServer.InBox.Count - 1
emailMessage = imapServer.InBox.GetMessage(count)
'email subjects get listed in a list Box
listemails.Items.Add(emailMessage.Subject)
Next
Dim query = SearchQuery.SubjectContains("")
Dim uids = imapServer.InBox.Search(query)
Dim items = imapServer.InBox.Fetch(uids,MessageSummaryItems.UniqueId)
End Sub
End Class
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)