【发布时间】:2020-01-29 03:01:45
【问题描述】:
我想将正文中的动态单元格设置为粗体。
我希望电子邮件正文如下所示:
尊敬的用户,
以下请求在 I8.1 检查资源可用性:
测试项目
在请求的 ROM 中调用以下估计工作量(以小时为单位):10 和持续时间(以工作日为单位):2 你有我可以投入的命名资源吗?请尽快给我更新
谢谢你和最好的问候,
团队。
此代码有效,但我找不到加粗所需值的方法。
Sub Sendmail()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("D").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "E").Value) <> "0" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Resources awaiting assignment"
.Body = "Dear " & Cells(cell.Row, "C").Value _
& ", " _
& vbNewLine & vbNewLine & _
"The following request is in I8.1 Check Resource Availability: " _
& vbNewLine & vbNewLine & _
Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"The estimated effort below is called out in the request's ROM (in hours): " & Cells(cell.Row, "E").Value _
& _
" and duration (in business days): " & Cells(cell.Row, "F").Value _
& vbNewLine & vbNewLine & _
"Do you have a named resource I can put in for the effort called out? Please provide me with an update at the earliest" _
& vbNewLine & vbNewLine & _
"Thank you and best regards, " & vbNewLine & _
"Team."
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
我查看了一些关于在 VBA 中格式化电子邮件正文的帖子(例如 How to format email body?、formatting email body using VBA 或 Bolding Text with VBA)。
【问题讨论】: