使用 VB 脚本发送电子邮件时出错。需要知道下面的代码是否有问题?

Error when sending an email using VB Script. Need need to know if anything is wrong with this below code?

错误message:server 被拒绝的发件人地址 530 5.7.1.Client 未通过身份验证,无法从

发送匿名电子邮件

使用的脚本:

Set MyEmail=CreateObject("CDO.Message")
MyEmail.Subject="Test Email"
MyEmail.From="test@mail.com"
MyEmail.To="send@mail.com"
MyEmail.TextBody="Test Email"
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@mail.com" 
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="---------"
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusetsl") = True
MyEmail.Configuration.Fields.Update
MyEmail.Send
Set MyEmail=nothing

嗯,也许你可以使用我提供的这个资源

Imports System.Net.Mail
Public Class Form1

        Dim smtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        smtpServer.Credentials = New Net.NetworkCredential("email@gmail.com ", "pass")
        'using gmail
        smtpServer.Port = 587
        smtpServer.Host = "smtp.gmail.com"
        smtpServer.EnableSsl = True
        mail = New MailMessage()
        mail.From = New MailAddress("From@Gmail.Here")
        mail.To.Add("To@Gmail.Here")
        mail.Subject = "Your Subject"
        mail.Body = "Text Message Here"
        smtpServer.Send(mail)

更新:将端口号更改为 25 解决了该问题。谢谢!