老师,早上好,企业QQ邮箱配置了好久,都报错,在论坛上查了,测试也报错,两种方法都试了,现在把两种方法贴出来,请老师帮忙看下哪里错了,谢谢哈
[此贴子已经被作者于2024/9/24 8:20:35编辑过]
第二种Dim mail As new System.Web.Mail.MailMessage()
try
mail.To = "892846575@qq.com"
mail.From = "apqp@cscbearing.cn"
mail.Subject = "这是主题"
mail.BodyFormat = System.Web.Mail.MailFormat.Html
mail.Body = "这是内容"
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") '//身份验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mail.From) '//邮箱登录账号,这里跟前面的发送账号一样就行
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "753214Ss@#123") '//这个密码要注意:如果是一般账号,要用授权码企业账号用登录密码 yC9fda8tZxBcgEyH
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 587)'//端口
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true")'//SSL加密
System.Web.Mail.SmtpMail.SmtpServer = "smtp.qq.com" '//企业账号用smtp.exmail.qq.com
System.Web.Mail.SmtpMail.Send(mail)
msgbox("邮件发送成功 ")
catch ex As Exception
msgbox("邮件发送成功 : " & ex.Message )
End try
第一种怎么排序的乱七八糟,我重新贴下代码
Dim client As New System.Net.Mail.SmtpClient("smtp.cscbearing.cn", 25) '或者465 587
client.EnableSsl = True 'SSL
client.Credentials = New System.Net.NetworkCredential("apqp@cscbearing.cn", "753214Ss@#123") ' 前面的是密码,后面这个是授权码 yC9fda8tZxBcgEyH
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage()
message.From = new System.Net.Mail.MailAddress("apqp@cscbearing.cn","别名")
'message.To.Add(new System.Net.Mail.MailAddress("2450314695@qq.com","人名"))
message.To.Add("892846575@qq.com")
message.Subject = "邮件测试"
message.BodyEncoding = System.Text.Encoding.UTF8
Dim content As String
content &= "这是文字" & vbcrlf
content &= "也是文字"
message.Body = content
Try
client.Send(message)
msgbox("发送成功")
Catch ex As Exception
msgbox("发送失败:" & ex.message)
End Try
这种方法,报错:发送失败:参数或变量中有语法错误。 服务器响应为:mail from address must be same as authorization user
以下是引用漂亮美眉vszh在2024/9/24 8:18:00的发言:
第一种怎么排序的乱七八糟,我重新贴下代码
Dim client As New System.Net.Mail.SmtpClient("smtp.cscbearing.cn", 25) '或者465 587
client.EnableSsl = True 'SSL
client.Credentials = New System.Net.NetworkCredential("apqp@cscbearing.cn", "753214Ss@#123") ' 前面的是密码,后面这个是授权码 yC9fda8tZxBcgEyH
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
Dim message As New System.Net.Mail.MailMessage()
message.From = new System.Net.Mail.MailAddress("apqp@cscbearing.cn","别名")
'message.To.Add(new System.Net.Mail.MailAddress("2450314695@qq.com","人名"))
message.To.Add("892846575@qq.com")
message.Subject = "邮件测试"
message.BodyEncoding = System.Text.Encoding.UTF8
Dim content As String
content &= "这是文字" & vbcrlf
content &= "也是文字"
message.Body = content
Try
client.Send(message)
msgbox("发送成功")
Catch ex As Exception
msgbox("发送失败:" & ex.message)
End Try
老师,依旧没能查出原因。发件人、授权都查了,都没找到原因。并手动测试了发送,没异常。
老师您能帮忙看下吗?那个代码复制后就直接能在命令窗口处运行的
这个我们没有办法查。这个错误是邮件服务器返回的,它说地址和授权对就肯定不对,建议咨询一下邮箱的客服