I searched and followed the following link on Mr Excel:
http://www.mrexcel.com/forum/excel-questions/649148-email-userform-without-outlook.html
Refers to: email without outlook: http://www.rondebruin.nl/cdo.htm
Which provided code and tips which I have tried...
In the line of code below I use my correct 'password':
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
I have tried both '25' and '465' in the following line of code:
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'465' is the correct port, but I get the following VB error message:
"Run-time error '=2147220973 (80040213)': The transport failed to connect to the server."
The code appears to run fine right up until the error message appears. When I look at 'Debug'
to see where the code stopped it is on the line...'.Send' in the 'With' statement.
I have tried using Cox and gmail with the same result.
Have I missed something in the code, or where else might I look to sort this out?
My goal is to get this code to work, then modify it to send a pdf attachment.
I am using Windows 7 and Excel 2007.
Thank you in advance for any help.
Perpa
http://www.mrexcel.com/forum/excel-questions/649148-email-userform-without-outlook.html
Refers to: email without outlook: http://www.rondebruin.nl/cdo.htm
Which provided code and tips which I have tried...
In the line of code below I use my correct 'password':
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
I have tried both '25' and '465' in the following line of code:
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'465' is the correct port, but I get the following VB error message:
"Run-time error '=2147220973 (80040213)': The transport failed to connect to the server."
The code appears to run fine right up until the error message appears. When I look at 'Debug'
to see where the code stopped it is on the line...'.Send' in the 'With' statement.
I have tried using Cox and gmail with the same result.
Have I missed something in the code, or where else might I look to sort this out?
My goal is to get this code to work, then modify it to send a pdf attachment.
I am using Windows 7 and Excel 2007.
Thank you in advance for any help.
Perpa
Code:
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.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "capopat48@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.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 = "perpa48@gmail.com"
.CC = ""
.BCC = ""
.From = "capopat48@gmail.com"
.Subject = "New figures"
.TextBody = strbody
.Send
End With
End Sub