【发布时间】:2021-12-03 09:33:04
【问题描述】:
我尝试创建一个 vba 代码来帮助我向不同的客户发送电子邮件。
我将所有电子邮件正文放在具有特定格式的 Excel 文本框中。我现在遇到的问题是,当电子邮件正文插入电子邮件时,正文格式丢失了。
问题:如何保持文本框的格式?
Sub test_email_template()
Dim name, email, body, subject, copy, place, business As String
name = Range("B4").Value
email = Range("C4").Value
body = Format(ActiveSheet.TextBoxes("TextBox 1").Text)
subject = " Payment Summary Reports"
copy = Range("D2").Value
'replace name'
body = Replace(body, "Email Title", name)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = email
.cc = copy
.subject = subject
.body = body
.display
End With
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "Email(s) Sent!"
End Sub
下面是我要保留的文本框格式
【问题讨论】:
-
I put all email body in a text box in excel with specific formatting.具体是什么格式?