Send mail from Excel

G

Gaurav

I was using Example Code for sending mail from Excel esp. Outlook
object model (body) from http://www.rondebruin.nl - Mail a row to each
person in a range and I would like to make some changes to its macro
and need your help in that.
Currently, in the body of the mail, it takes only a particular row, is
it possible to add personalised message along with the excel row.
Secondly, is it possible to edit the range of data to paste in the
body of the mail. For example, instead of sending the entire row, i
would like to send edited row (with some of the columns hidden).

Can anyone please help me with this.

Regards,

Gaurav
 
R

Ron de Bruin

hi Gaurav

1:
If you want to add a few text lines above the HTML body you can add this to the macro.
Note: This is not working if Word is your mail editor, you can change this setting
in Outlook: Tools>Options>.Mail Format tab

Add this Dim line
Dim StrBody As String


Build the string you want to add

StrBody = "This is line 1" & "<br>" & _
"This is line 2" & "<br>" & _
"This is line 3" & "<br><br><br>"

Or use this for cell values

StrBody = Sheets("Sheet2").Range("A1").Value & "<br>" & _
Sheets("Sheet2").Range("A2").Value & "<br>" & _
Sheets("Sheet2").Range("A3").Value & "<br><br><br>"


And change the HTMLBody line to this
.HTMLBody = StrBody & RangetoHTML(rng)


2: Hide the columns also in the macro before you create the mails
 
G

Gaurav

Thanks Ron!!

hi Gaurav

1:
If you want to add a few text lines above the HTML body you can add this to the macro.
Note: This is not working if Word is your mail editor, you can change this setting
in Outlook: Tools>Options>.Mail Format tab

Add this Dim line
    Dim StrBody As String

Build the string you want to add

    StrBody = "This is line 1" & "<br>" & _
              "This is line 2" & "<br>" & _
              "This is line 3" & "<br><br><br>"

Or use this for cell values

    StrBody = Sheets("Sheet2").Range("A1").Value & "<br>" & _
              Sheets("Sheet2").Range("A2").Value & "<br>" &_
              Sheets("Sheet2").Range("A3").Value & "<br><br><br>"

And change the HTMLBody line to this
        .HTMLBody = StrBody & RangetoHTML(rng)

2: Hide the columns also in the macro before you create the mails
 

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