PDA

View Full Version : Sending mail via yahoo using CDO



khaledocom
03-03-2011, 05:01 AM
I tried the following code to send mail using my account on Yahoo but I'm getting error: '-2147220973 (800420213)':
The transport failed to connect to the server.

Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
' Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= "smtp.sbcglobal.yahoo.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"

With iMsg
Set .Configuration = iConf
.To = "khaledocom@hotmail.com"
.CC = ""
.BCC = ""
.From = """khaledocom@yahoo.com"
.Subject = "New figures"
.TextBody = strbody
.Send
End With

End Sub


Please help, Thankful for your help.

Charlize
03-03-2011, 06:04 AM
Do you pay for this service. I think you can only use the smtp server with mail plus option. Try inserting this coding into your coding (replace the part from iconf.load until End With) :
iConf.Load -1 ' CDO Source Defaults
Set 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") = "username"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.here the yahoo server.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
Charlize

khaledocom
03-06-2011, 09:45 PM
Thanks Charlize (http://www.vbaexpress.com/forum/member.php?u=5928) for your reply but why should I add user name and password since the mail web session is opened before I run the code. what's the smtp server for yahoo then, I tried many but still not working.

Thanking you again for your kind help and support with this regarding.