如何解决如何使用mailkit在webview2中显示html电子邮件
我目前正在使用 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 举报,一经查实,本站将立刻删除。