user2862496
user2862496

Reputation: 247

Inserting text in Email body using VBA

I am using the following VBA macro to mail a range of cells from Excel

ActiveSheet.Range("A2:Q133").Select
ActiveWorkbook.EnvelopeVisible = True

   With ActiveSheet.MailEnvelope
    .Introduction = "demo"
      .Item.To = "[email protected]"
      .Item.Subject = "Testing mail"
      .Item.Send
   End With 

I want to modify the code to insert some text in the end. I tried using

.Item.HTMLBody = "Random text"

but the mail doesnt contain the text.

Please let me know if i am doing anything wrong and what is the correct way to do it. Thanks in advance!

Upvotes: 3

Views: 6703

Answers (1)

mucio
mucio

Reputation: 7119

With MailEnvelope you send the whole sheet as body of your email.

Introduction allows you to add some text before a mail item, but you have no other way to add something at the end than append something to the Excel sheet.

Even if you modify the Body or the HTMLBody, this doesn't have effect on the email.

Maybe you could try to add same the message as draft and reopen it as a different object to modify it, but it seems over complicated. Much easier just to add some temporary text at the end of the excel spreasheet and remove it after .Item.Send

Upvotes: 1

Related Questions