[英]Adding signature in Outlook email after .Body using Excel VBA
In Excel VBA I want to create a macro to send a letter via Outlook.在 Excel VBA 我想创建一个宏来通过 Outlook 发送一封信。
I need a signature, but I cannot create it, because I have a .Body
part and I need to paste a dynamic range of cells after it.我需要一个签名,但我无法创建它,因为我有一个
.Body
部分,我需要在它后面粘贴一个动态范围的单元格。
With newEmail
.Display
.SentOnBehalfOfName = ""
.To = ""
.CC = ""
.Subject = ""
.BodyFormat = olFormatHTML
.Body = "Good day" & vbCrLf & "bla bla "
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
Sheet1.Range("G128", ActiveSheet.Range("G128").End(xlDown)).Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.Paste
.Display
.Send
What and where should I add, to add a signature after the code pastes the range?我应该在代码粘贴范围后添加什么和在哪里添加签名?
PS .Body
before the range is necessary. PS
.Body
之前的范围是必要的。
In Excel VBA I want to create a macro to send a letter via Outlook.在 Excel VBA 中,我想创建一个宏来通过 Outlook 发送一封信。
I need a signature, but I cannot create it, because I have a .Body
part and I need to paste a dynamic range of cells after it.我需要一个签名,但我无法创建它,因为我有一个
.Body
部分,我需要在它之后粘贴一个动态范围的单元格。
With newEmail
.Display
.SentOnBehalfOfName = ""
.To = ""
.CC = ""
.Subject = ""
.BodyFormat = olFormatHTML
.Body = "Good day" & vbCrLf & "bla bla "
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
Sheet1.Range("G128", ActiveSheet.Range("G128").End(xlDown)).Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.Paste
.Display
.Send
What and where should I add, to add a signature after the code pastes the range?在代码粘贴范围后,我应该添加什么以及在哪里添加签名?
PS .Body
before the range is necessary. PS
.Body
之前的范围是必要的。
Create a new range in the Word document and call Range.insertFile()
to insert the HTML file of the signature.在Word文档中新建一个区域,调用
Range.insertFile()
插入签名的HTML文件。
If you construct a signature in the code and store it in a variable, eg Signature, you could do something like this...如果您在代码中构建一个签名并将其存储在一个变量中,例如 Signature,您可以这样做......
With newEmail
.SentOnBehalfOfName = ""
.To = ""
.CC = ""
.Subject = ""
.BodyFormat = olFormatHTML
.Body = "Good day" & vbCrLf & "bla bla "
Sheet1.Range("G128", ActiveSheet.Range("G128").End(xlDown)).Copy
With .GetInspector.WordEditor.Range
.Collapse 0
.Paste
.Collapse 0
.Text = vbCrLf & Signature
.Style = "No Spacing"
End With
.Display
'.Send
End With
Try to add at the end.body =.body &.HTMLbody尝试在末尾添加.body =.body &.HTMLbody
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.