首页 > 解决方案 > 预期:行号或标签或语句或语句结尾

问题描述

在此处输入图像描述

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

我想要电子邮件正文如下

中心标志“图像”

亲爱的“客户名称”'来自用户表单

欢迎来到我们的平台

问候,

帕思

标签: excelvbauserform

解决方案


正如@braX 提到的,您需要使用&来连接文本和_连接行。我添加了<br/>标签,因为它们用于 html 换行符。

尝试这个:

.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

推荐阅读