excel - 按原样将文本从 Excel 复制到 Outlook 邮件
问题描述
我正在尝试从 Excel 创建一个自动 Outlook 消息。问题是我当前在 Outlook 消息中的代码文本没有像最初在 Excel 中键入的那样格式化(请参见下面的屏幕截图)。有没有办法让它至少换行(保持换行符)?
因此,如果在 Excel 中输入:
This is text
and it continues
on the next line.
One line break in between also.
它会在 Outlook 消息中显示相同吗?没有像现在这样的班轮...
With olMail
.To = "office@um.com"
.Subject = olSubject
.HTMLBody = "<BODY style=font-size:11pt;font-family:Calibri>" & _
"MESSAGE" & "<br>" & _
"Number:" & ThisWorkbook.Worksheets("Other Data").Range("P14").Value & "-" & ThisWorkbook.Worksheets("Other Data").Range("I140").Value & "<br>" & _
"Include attachments." & "<br>" & _
"Total:" & ThisWorkbook.Worksheets("Other Data").Range("P38").Value & "<br>" & _
"Cover notes:" & ThisWorkbook.Worksheets("MAIN").Range("B90").Value & "<br>" & _
"§§§" & _
"</BODY>" '& .HTMLBody
我在 Excel 中有这种格式的数据:
然后它在 Outlook 中显示如下:
解决方案
尝试将换行符替换为其 HTML 等效项。因此,例如,替换vbLf
为<br>
...
"Cover notes:" & Replace(ThisWorkbook.Worksheets("MAIN").Range("B90").Value, vbLf, "<br>") & "<br>" & _
推荐阅读
- postgresql - 查询使用关键对象名称的地方
- netsuite - Netsuite 高级 PDF - 检索自定义首选项
- azurekinect - Kinect DK 创建录音
- googletest - 预期失败,但测试仍然通过
- graphql - 如何处理返回布尔值的 GraphQL 查询?
- javascript - 在 JavaScript 中将 src 属性更改为 data-src
- react-native - React Native:如何支持外接 iPad 键盘(UIKeyCommand)?
- url - 带有“&rm=minimal”的 Google 表格 URL 可以完美运行——但会破坏脚本
- python - 使用 geopandas 绘制德国各州
- bash - 如何在 Bash 中将一些秒数添加到日期时间戳?