0

enter image description here

Sub Send_Email()
Dim sh As Worksheetenter code here

 sh = ThisWorkbook.Sheets("CREmail")

With Selection.Parent.MailEnvelope.Item
.TO = ClientRegistration.txtemail.Value
.Subject = "Thank You for Registration"
.Attachments.Add sh, 1, 0
    .HTMLBody = "<img src=""cid:WoService.png""height=520 width=750>"
                "Dear" < ClientRegistration.txtname.Value >
                "Thank you For Registration"
                "Regards"
                "Parth"
    .Display
.Send
End With

MsgBox "Done"

End Sub

i want email text body as below

Logo at Center"Image"

Dear "Client Name" 'from userform

Welcome to Our Plateform

Regards,

Parth

braX
  • 11,506
  • 5
  • 20
  • 33
Parth Parmar
  • 1
  • 1
  • 2
  • 1
    You have to use `&` to concatenate strings - and if you dont want them all on the same line, you also have to use `_` - https://stackoverflow.com/questions/22854386/how-to-continue-the-code-on-the-next-line-in-vba - if you want a new line in the email, you need to use html line break - `
    `
    – braX Jul 29 '20 at 21:36

1 Answers1

0

As @braX mentioned, you need to use & to concatenate text and _ to join lines. I added the <br/> tags as they are used for html line breaks.

Try this:

.Attachments.Add sh, 1, 0
    .HTMLBody = "<img src=""cid:WoService.png""height=520 width=750><br/>" & _
                "Dear <" & ClientRegistration.txtname.Value & "><br/>" & _
                "Thank you For Registration<br/>" & _
                "Regards<br/>" & _
                "Parth"
    .Display
.Send
braX
  • 11,506
  • 5
  • 20
  • 33
Mike67
  • 11,175
  • 2
  • 7
  • 15
  • Dear Sir, i have just checked your code, it work fine..but when i got email then there show email attachment, which is logo image...i don't want it as attachment..it will show only in email body.. is it possible? – Parth Parmar Jul 30 '20 at 06:09