I have written an application to be used by our Seniors Captain at the Golf Club. It allows him to email Teamsheets to select players directly from Excel using Outlook. I want to adapt the application to use other mail packages other than Outlook.
Using code supplied from Ron de Bruin's Web site I used this test program to test out the method.
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") _
= "my.server.co.uk"
.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 = "my@email.address.uk"
.CC = ""
.BCC = ""
.From = """Dave"" <my@email.address.uk>"
.Subject = "New figures"
.TextBody = strbody
.Send
End With
End Sub
With Port smtpserverport set to 25, I get this error message
Run-time error '-2147220978(8004020e)':
The server rejected the sender address. The server response was: 550 Access denied - Invalid HELO name (see RFC2821.4.1.1.1)
With the smtpserverport set to 465 I get
Run-time error '-2147220978(80040213)':
The transport failed to connect to the server
The code above was used on a computer using Outlook.
My Outlook application uses port 465.
I got the same result from a laptop using Windows Live Mail.
Can anyone tell me what is wrong?
Dave
Bookmarks