Use variable as email reipient names
Hi,
I'm not an ace on this but just a couple things I noticed:
What you are copying your data to is a string not an array, and also, aren't
different recipients separated by a semicolon rather than a comma (or will
either work?).
Try changing:
ActiveWorkbook.SendMail Array(strRecipients), "Just a Test", "Testing Code
To this:
ActiveWorkbook.SendMail strRecipients, "Just a Test", "Testing Code
If it still fails try changing:
strRecipients = strRecipients & """, """ & Sheets("Email
Recipients").Range("A" & varCurRow).Value
To This (comma to semicolon):
strRecipients = strRecipients & """; """ & Sheets("Email
Recipients").Range("A" & varCurRow).Value
Hope this may help.
"Mr B" wrote:
I am attempting to read a list of email addresses into a variable and then
use that variable in the SendMail function. If I use hard coded email
addresses all is fine, but when I try to store the names in the variable and
use the variable it errors out.
Here is my code:
Dim strRecipients As String
'other variables defined
While varCurRow < varLastRow + 1
'read the list of email recipients
Sheets("Email Recipients").Range("A" & varCurRow).Select
If strRecipients = "" Then
strRecipients = "'" & Sheets("Email Recipients").Range("A" &
varCurRow).Value
'strRecipients = """ & range.("A3").Value & """
Else
strRecipients = strRecipients & """, """ & Sheets("Email
Recipients").Range("A" & varCurRow).Value
End If
varCurRow = varCurRow + 1
'cntr = cntr + 1
Wend
ActiveWorkbook.SendMail Array(strRecipients), "Just a Test", "Testing Code
Only"
Any help is appreciated.
Mr B
|