0

我们第一次使用 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 语句行。

4

1 回答 1

2

尝试这个:

    Dim objSMTP As New MailBee.Smtp

同时,这不是必需的:

    objSMTP = CreateObject("MailBee.SMTP")

它与 New MailBee.Smtp 行做同样的事情

于 2012-06-14T20:05:11.193 回答