gpt4 book ai didi

vba - 在 Word VBA 中使用 .body 而不是 .htmlbody 将我的电子邮件正文的一部分设为粗体

转载 作者:行者123 更新时间:2023-12-03 21:30:30 25 4
gpt4 key购买 nike

我正在尝试将电子邮件 VBA 正文中的特定文本加粗。在当前状态下,我无法格式化 .body 下的任何文本.

但是,当我更改为 .html body 时,我可以加粗文本。例如,如果我使用“< b>JOB NUMBER”,文本“JOB NUMBER”是粗体的,但我的电子邮件的整个正文会丢失所有行空格。

您的帮助将不胜感激。谢谢

    Private Sub sendemail_Click()


Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save

With EmailItem
.Subject = "QDR" & " " & TextBox22.Value & "_" & TextBox21.Value & "_" & ComboBox2.Value & "_" & combobox1.Value
**.Body** = "Attached QDR Request form is for the following: " & vbCrLf & _
"" & vbCrLf & _
"JOB NUMBER: " & vbCrLf & _
TextBox21.Value & vbCrLf & _
"" & vbCrLf & _
"QDR NUMBER: " & vbCrLf & _
TextBox22.Value & vbCrLf & _
"" & vbCrLf & _
"CONDITION: " & vbCrLf & _
combobox1.Value & vbCrLf & _
"" & vbCrLf & _
"HARTNESS PART NUMBER: " & vbCrLf & _
TextBox23.Value & vbCrLf & _
"" & vbCrLf & _
"REQUIRED DATE: " & vbCrLf & _
TextBox31.Value & vbCrLf & _
"PART REQUIRED SOONER THAN SET LEAD TIME: " & vbCrLf & _
TextBox30.Value & vbCrLf & _
"" & vbCrLf & _
"BRIEF DESCRIPTION OF REQUEST: " & vbCrLf & _
TextBox25.Value


.To = "XXXXX@XXXXX.com;"
.CC = "XXXXX@XXXXX.com;" & "XXXXX@XXXXX.com;"
.Importance = olImportanceNormal 'Or olImportanceHigh Or olImportanceLow
.Attachments.Add Doc.FullName
.Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing


End Sub

EXAMPLE PICTURE

最佳答案

您可以继续使用 HTML,只需将回车符替换为 html 的 <br>换行。请记住,用于设置 html 内容样式的每个内联标记(无 css)都是有效的。因此,您可以自由选择各种字体、颜色、大小,甚至是网络图片!

msg = "Attached QDR Request form is for the following: <br><br>" _
& "<b> JOB NUMBER:</b><br>" _
& TextBox21.Value & "<br><br>" _
& "<b> QDR NUMBER: </b><br>" _
& TextBox22.Value & "<br><br>" _
& "<b> CONDITION: </b><br>" _
& combobox1.Value & "<br><br>" _
& "<b> HARTNESS PART NUMBER: <br>" _
& TextBox23.Value & "<br><br>" _
& "<b> REQUIRED DATE: </b><br><br>" _
& "PART REQUIRED SOONER THAN SET LEAD TIME: <br>" _
& TextBox30.Value & "<br><br>" _
& "<b>BRIEF DESCRIPTION OF REQUEST: </b><br>" _
& TextBox25.Value

...
.HTMLBody = msg

或者,使用 html 表格更好地对齐:
msg = "Attached QDR Request form is for the following: <br><br>" _
& "<table>" _
& "<tr><td><b> JOB NUMBER: </b></td><td>" & TextBox21.Value & "</td></tr>" _
& "<tr><td><b> QDR NUMBER: </b></td><td>" & TextBox22.Value & "</td></tr>" _
& "<tr><td><b> CONDITION: </b></td><td>" & combobox1.Value & "</td></tr>" _
& "<tr><td><b> HARTNESS PART NUMBER: <b></td><td>" & TextBox23.Value & "</td></tr>" _
& "<tr><td><b> REQUIRED DATE: </b></td></tr>" _
& "<tr><td> PART REQUIRED SOONER THAN SET LEAD TIME: </td><td>" & TextBox30.Value & "</td></tr>" _
& "<tr><td> BRIEF DESCRIPTION OF REQUEST: </td><td>" & TextBox25.Value & "</td></tr>" _
& "</table>"

...
.HTMLBody = msg

关于vba - 在 Word VBA 中使用 .body 而不是 .htmlbody 将我的电子邮件正文的一部分设为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37709270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com