我们第一次使用 MailBee,但收到此错误:
'Smtp' is ambiguous in the namespace 'MailBee.SmtpMail'.
这是什么意思,我们如何创建 objSMTP 对象?
完整的编码如下所示:
Imports MailBee
Imports MailBee.DnsMX
Imports MailBee.Mime
Imports MailBee.SmtpMail
Imports MailBee.Pop3Mail
Imports MailBee.ImapMail
Imports MailBee.Security
Imports MailBee.AntiSpam
Imports MailBee.Outlook
Imports MailBee.Pdf
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim objSMTP As New Smtp
objSMTP = CreateObject("MailBee.SMTP")
' Enable logging SMTP session into a file
objSMTP.EnableLogging = True
objSMTP.LogFilePath = "C:\emad.txt"
objSMTP.ClearLog()
objSMTP.LicenseKey = "This part is hidden"
' Set SMTP server name
objSMTP.ServerName = "mail.bluebottle.com"
' Enable SMTP authentication
objSMTP.AuthMethod = 2
' Set authentication credentials
objSMTP.UserName = "This part is hidden"
objSMTP.Password = "secret"
' Set message properties
objSMTP.FromAddr = "This part is hidden"
objSMTP.ToAddr = "someone@gmail.com"
objSMTP.Subject = "Test"
objSMTP.BodyText = "Body of the test message"
' Try to send message
If objSMTP.Send Then
MsgBox("Sent successfully")
Else
MsgBox("Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc)
End If
End Sub
End Class
有错误的行是 dim 语句行。