Mail a row or rows to each person in a range

G

Gaurav

Hi,

I am using send mail macro from Ron de Bruin's site at
http://www.rondebruin.nl/sendmail.htm and its example workbook three
with option to Mail a row or rows to each person in a range. Is it
possible to have the name of the person to whom the mail is being send
in the body of the mail. I have tried adding following code and add
the StrBody to .HtmlBody -
StrBody = "Hi " & Cws.Cells(Rnum, 1).Value & ","
But it did not work and showed some error message. Error seems to be
in the formula being used to pick up the name. And is it possible to
pick only first name as the name I have in the column is complete
name. I understand that it can be easily done by using Left and Mid
function. But I am not being able to use those functions within macro.

Can anyone please assist me on that.

Regards,

Gaurav
 
P

Per Jessen

Hi

Untested, but this should do it:

NameStr = Cws.Cells(rnum, 1).Value
FirstName = Left(NameStr, WorksheetFunction.Find(" ", NameStr) - 1)
StrBody = "Hi " & FirstName & "," & vbLf

..HTMLBody = StrBody & RangetoHTML(rng)

Regards,
Per
 
G

Gaurav

Thank you Per, it now works.

Hi

Untested, but this should do it:

NameStr = Cws.Cells(rnum, 1).Value
FirstName = Left(NameStr, WorksheetFunction.Find(" ", NameStr) - 1)
StrBody = "Hi " & FirstName & "," & vbLf

.HTMLBody = StrBody & RangetoHTML(rng)

Regards,
Per

"Gaurav" <[email protected]> skrev i meddelelsen





- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top