Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Pass Arguments to CDO_Mail_Auto

I am using Ron DeBruin's CDO_Mail_Auto routine. I would like to call
this routine from another VBA routine. I want to pass the value of
cell A1 and cell A3 into CDO_Mail_Auto, so that the value of those
cells become part of the emailed message.

Basically, I want to evaluate a cell at A7 for "TRUE" or "FALSE", and
if "TRUE", send an email about that row of data, specifically with the
contents of A1 and A3.

I'll attach my working copy of CDO_Mail_Auto here, with the email and
password info XXXXX'd out. Any help would be appreciated.

Thanks
John

--------------------------------------------

Sub CDO_Mail_Auto()
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/
smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/
sendusername") = "
.Item("http://schemas.microsoft.com/cdo/configuration/
sendpassword") = "XXXXXXX"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpserver") = "smtp.gmail.com"

.Item("http://schemas.microsoft.com/cdo/configuration/
sendusing") = 2
.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 = "XXXXXXXXX"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail
example
' It will use your Gmail address automatic. But you can add
this line
' to change the reply address .ReplyTo = "
.From = """XXXXXXXX"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Pass Arguments to CDO_Mail_Auto

See the tips on the CDO page

Dim strbody As String
With Sheets("Sheet1")
strbody = "Hi there" & vbNewLine & vbNewLine & _
.Range("A1") & vbNewLine & _
.Range("A2") & vbNewLine & _
.Range("A3") & vbNewLine & _
.Range("A4")
End With




--

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


"Johnny" wrote in message ...
I am using Ron DeBruin's CDO_Mail_Auto routine. I would like to call
this routine from another VBA routine. I want to pass the value of
cell A1 and cell A3 into CDO_Mail_Auto, so that the value of those
cells become part of the emailed message.

Basically, I want to evaluate a cell at A7 for "TRUE" or "FALSE", and
if "TRUE", send an email about that row of data, specifically with the
contents of A1 and A3.

I'll attach my working copy of CDO_Mail_Auto here, with the email and
password info XXXXX'd out. Any help would be appreciated.

Thanks
John

--------------------------------------------

Sub CDO_Mail_Auto()
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/
smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/
sendusername") = "
.Item("http://schemas.microsoft.com/cdo/configuration/
sendpassword") = "XXXXXXX"
.Item("http://schemas.microsoft.com/cdo/configuration/
smtpserver") = "smtp.gmail.com"

.Item("http://schemas.microsoft.com/cdo/configuration/
sendusing") = 2
.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 = "XXXXXXXXX"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail
example
' It will use your Gmail address automatic. But you can add
this line
' to change the reply address .ReplyTo = "
.From = """XXXXXXXX"" "
.Subject = "Important message"
.TextBody = strbody
.Send
End With

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass variables as arguments of a function Excel-craze Excel Worksheet Functions 1 August 12th 09 11:48 AM
OnTime: Pass Object Arguments Greg Lovern Excel Programming 6 October 12th 07 12:50 AM
How to pass arguments to vlookup in VBA mathewg Excel Programming 4 January 20th 06 12:34 PM
Run/execute VBS and pass arguments Claud Balls Excel Programming 3 February 4th 05 08:34 AM
How to pass arguments from ThisWorkbook to a UserForm strataguru[_4_] Excel Programming 1 October 7th 03 11:29 PM


All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"