如何在Outlook电子邮件中自动调整Excel区域



我在Outlook电子邮件中发送了一个由多个表组成的Excel区域。

我想在显示在电子邮件中时自动调整内容。

With newEmail
.to = 123@email.com
.CC = ""
.BCC = ""
.Subject = "My Report"
.HTMLBody = strbody & _
HMOimg _
& .HTMLBody

.Display
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor

'This Range consist of 3 tables, I just copied the whole range    
ThisWorkbook.Worksheets("MyData").Range("B24:Q133").Copy
'This one Autofit the column not the content itself in excel sheet,
' what I want to do is to Autofit the "content" when paste in the email
ThisWorkbook.Worksheets("HMO Overall AHT").Range("B24:Q133").Columns.autofit

pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)

.Display

首先,确保在设置HTMLBody属性时处理格式良好的HTML字符串。

传递给PasteAndFormat方法的wdFormatPlainText参数用于将内容粘贴为无格式的纯文本。我建议选择其他选项,如wdFormatOriginalFormatting等。

最新更新