【问题标题】:Whats wrong with my emailing code?我的电子邮件代码有什么问题?
【发布时间】:2012-03-05 22:49:27
【问题描述】:

这是我的代码:

Public Class form1

Sub SendMail()
    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Object
    iMsg = CreateObject("CDO.Message")
    iConf = CreateObject("CDO.Configuration")
    iConf.Load(-1) ' CDO Source Defaults
    Flds = iConf.Fields
    With Flds
        .Item("http://schemas.Microsoft.Com/cdo/configuration/smtpusessl") = True
        .Item("http://schemas.Microsoft.Com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.Microsoft.Com/cdo/configuration/sendusername") = "myemail@gmail.com"
        .Item("http://schemas.Microsoft.Com/cdo/configuration/sendpassword") = "mypassword"
        .Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserver") = "smtp.gmail.com"
        .Item("http://schemas.Microsoft.Com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserverport") = 25
        .Update()
    End With

    With iMsg
        .Configuration = iConf
        .To = "obroomhall@gmail.com"
        .From = "obroomhall@gmail.com"
        .Subject = "subject"
        .TextBody = "test"
        .Send()
    End With

End Sub

End Class

显然我将 myemail 和 mypassword 更改为我需要的,但这不会返回错误代码,也不会发送电子邮件!我做错了什么?

【问题讨论】:

标签: email smtp gmail sendmail with-statement


【解决方案1】:

smtp.gmail.com 使用端口 465 进行 SSL 连接。

【讨论】:

  • 为什么会有任何改变?该端口是否通常被计算机阻止?
  • 端口 25 用于未加密的流量(除非客户端使用 STARTTLS 命令)
猜你喜欢
  • 2013-07-31
  • 2014-09-27
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 2017-08-26
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
相关资源
最近更新 更多