View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Error in Sending Email via CDO

Hi Danniel

Do you use Win 2000 or win XP ?
Are you online when you run the sub?

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Danniel Chen" wrote in message ...
I got same error message after commented the lines (Flds).
Is this only for my computer?

"Ron de Bruin" wrote:

Hi Danniel

If you have a account in OE you don't need the commented lines
in my examples.
Try it without them

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Danniel Chen" wrote in message
...
I stole the following code from Ron De Bruin's website with minor modification.
The SMTP server name "smtp.sbcglobal.yahoo.com" is from my ISP.
The SMTP server name is the same as I set up my outlook express outgoing
mail and which works fine.
When I tried to execute the following code, the got the following error
message:

------------------------------------------------
Run-time error '-2147220975(80040211)'
The message could not be sent to the SMTP server.
The transport error code was 0x80040217.
The server response is not available.
------------------------------------------------

Any suggestion to remove the error message?
Thanks a lot.

Danniel CHEN

Houston, TX
U.S.A

P.S. My outlook express (using same account and SMTP server) works fine.

========= CODE ========= CODE =========
Sub SendEmail()
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant

Application.ScreenUpdating = False
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

With iMsg
Set .Configuration = iConf
.To = "
.CC = ""
.BCC = ""
.From = """ABC ZZZ"" "
.Subject = "This is a test"
.TextBody = "Hi there"
'.AddAttachment "C:/" & WBname
' You can add any file you want with this line .AddAttachment
"C:/Test.txt"
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing
Application.ScreenUpdating = True
End Sub
================================================== =======