ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel CDO (https://www.excelbanter.com/excel-programming/410571-excel-cdo.html)

SQL Servant

Excel CDO
 
I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
..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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant


John Bundy

Excel CDO
 
My first guess, did you change this:
..To = "



--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"SQL Servant" wrote:

I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
.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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant


Ron de Bruin

Excel CDO
 
Have you fill in your smtp sever when you use the commented code ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
.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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant


SQL Servant

Excel CDO
 
I did fill in the smtp server and (in reply to John Bundy) I did change the
email address to mine (From and To).... Still no joy.

SQL Servant

"Ron de Bruin" wrote:

Have you fill in your smtp sever when you use the commented code ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
.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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant



Ron de Bruin

Excel CDO
 
No errors ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I did fill in the smtp server and (in reply to John Bundy) I did change the
email address to mine (From and To).... Still no joy.

SQL Servant

"Ron de Bruin" wrote:

Have you fill in your smtp sever when you use the commented code ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
.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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant



SQL Servant

Excel CDO
 
No errors. Nothing happens.

"Ron de Bruin" wrote:

No errors ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I did fill in the smtp server and (in reply to John Bundy) I did change the
email address to mine (From and To).... Still no joy.

SQL Servant

"Ron de Bruin" wrote:

Have you fill in your smtp sever when you use the commented code ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"SQL Servant" wrote in message ...
I'm trying to bypass Outlook to send an email with a csv attachment. I used
the code provided by Ron De Bruin (http://www.rondebruin.nl/cdo.htm):
- - - - -
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") _
' = "Fill in your SMTP server here"
'
.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 = "
.CC = ""
.BCC = ""
.From = """Ron"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
- - - - -
... but nothing happens when I run the macro, regardless of whether the
configuration lines are commented or not.

Any advice greatly appreciated.

SQL Servant





All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com