Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to pass variables as arguments of a function | Excel Worksheet Functions | |||
OnTime: Pass Object Arguments | Excel Programming | |||
How to pass arguments to vlookup in VBA | Excel Programming | |||
Run/execute VBS and pass arguments | Excel Programming | |||
How to pass arguments from ThisWorkbook to a UserForm | Excel Programming |