我们第一次使用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
有错误的行是昏暗的语句行。
答案 0 :(得分:2)
试试这个:
Dim objSMTP As New MailBee.Smtp
与此同时,这不是必需的:
objSMTP = CreateObject("MailBee.SMTP")
它与New MailBee.Smtp行
的作用相同