过去,我通过电子邮件“9990001111@messaging.sprintpcs.com”向我的Sprint电话发送了一条短信,并且它运行良好。现在我认为IT部门已经改变了一些东西,因为它不会经历。我这样说是因为在.NET中没有问题:
Dim mailClient As New SmtpClient("mail.mycompany.com")
Dim fromAddress As String = "Me.Developer@mycompany.com"
Dim toAdddress As String = "9990001111@messaging.sprintpcs.com"
'subject and body text depend on text message type
Dim subj As String = "", body As String = ""
subj = "Warning: Low trip count on 2014-02-06"
body = "Trip count <= 200. Please review log file."
With mailClient
Debug.Print("Host=" & .Host)
Debug.Print("Port=" & .Port)
Debug.Print("DeliveryMethod=" & .DeliveryMethod.ToString)
Debug.Print("EnableSsl=" & .EnableSsl.ToString)
Debug.Print("UseDefaultCredentials=" & .UseDefaultCredentials)
End With
'send the email
mailClient.Send(fromAddress, toAdddress, subj, body)
在我的公司Outlook客户端中,我可以手动创建电子邮件并将其发送到同一个电子邮件地址,这样就不会有任何问题。
现在在VB6中使用CDO我尝试使用所有相同的属性,但它没有到达。我甚至在一个gmail地址添加了一个CC,它到达那里但不到手机。这是VB6 / CDO代码的样子:
'use CDO to setup an email object
Dim cdoConfig As CDO.Configuration
Dim cdoMessage As CDO.Message
Dim cdofields As Object
'Create new configuration object
Set cdoConfig = New CDO.Configuration
Set cdofields = cdoConfig.Fields
Set cdoMessage = New CDO.Message
With cdofields
.Item(cdoSMTPServer) = "mail.mycompany.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSendUsingMethod) = cdoSendUsingPort 'Send the message using the network (SMTP over the network).
.Item(cdoSMTPAuthenticate) = cdoAnonymous
.Item(cdoSMTPUseSSL) = False 'Use SSL for the connection (True or False)
.Item(cdoSMTPConnectionTimeout) = 60
'if mail server requires outgoing authentication uncomment the lines below and use a valid email address and password.
'.Item(cdoSMTPAuthenticate) = cdoBasic 'basic (clear-text) authentication
'.Item(cdoSMTPAuthenticate) = cdoNTLM
'.Item(cdoSMTPUseSSL) = True
'.Item(cdoSendUserName) = "Joe Dirt"
'.Item(cdoSendPassword) = "doughnuts"
.Update
End With
DoEvents
'set message configuration
Set cdoMessage.Configuration = cdoConfig
'set message contents
With cdoMessage
.Sender = "Me.Developer@mycompany.com"
.From = "Me Developer"
.Subject = "Warning: Low trip count on 2014-02-06"
.TextBody = "Trip count <= 200. Please review log file."
.To = "9990001111@messaging.sprintpcs.com"
.CC = "me.developer@gmail.com"
End With
'send message
cdoMessage.Send
无法弄清楚为什么它适用于.NET和本机Outlook,而不适用于VB6 / CDO。
答案 0 :(得分:0)
看起来您正在使用CDO通过mail.mycompany.com中继邮件。 mail.mycompany.com的邮件服务器日志应显示a)mail.mycompany.com是否收到了来自您的应用程序的消息,如果是,b)是否成功发送到9990001111@messaging.sprintpcs.com。如果,日志不应显示失败的原因。从邮件服务器日志中,您应该能够找出问题。