我正在尝试编写一个宏来发送预设回复。我遇到的问题是正文太长,无法在我的代码中一行写完。我不知道如何添加第二段正文。我还想在回复的底部留下我的名字——签名样式。尝试运行宏时收到错误,提示行太长。有人能帮帮我吗?这是我目前得到的结果。
Sub EmailReply()
Dim Reply As Outlook.MailItem
Dim Original As Outlook.MailItem
Set Original = Application.ActiveExplorer.Selection(1)
Set Reply = Original.Reply
Reply.Subject = "In reference to your inquiry."
Reply.Body = "Dear Client," & vbNewLine & vbNewLine & " We thank you for consulting our firm regarding your legal issue. Unfortunately, upon a review of the information provided we are unable to assist you at this time. We encourage you to seek another legal option as there may be a strict statue of limitation that may extinguish your legal rights in your manner." & vbNewLine & " Although you did not retain us in this matter, we encourage you to contact us in the future for any legal needs or questions that you may have. Of course, there is no charge for consultation."
Reply.Display
End Sub
答案1
尝试使用vbNewLine
如下_
方法:
Reply.Body = "Dear Person" & vbNewLine & vbNewLine & _
"Line1" & vbNewLine & _
"Line2" & vbNewLine & _
"Line3" & vbNewLine & vbNewLine & _
"Sincerely," & vbNewLine & _
"Me"
vbNewLine
代表换行符
_
告诉 VBA 当前语句尚未完成。
答案2
我还没有在 Ms Outlook 中使用过 VBA,或者根本没有使用过大部分 VBA,但如果有行长度限制,你可以定义单独的变量并将它们连接起来
例如 a="asdf" b="qwert" c= a & vbNewLine & b
因此,您已经知道如何连接字符串,但您也可以使用单独的变量
答案3
您是否希望文本在电子邮件中显示为多个段落,还是仅在代码中显示为单独的行?
对于前者:
eply.Body = "Dear Client," & vbNewLine & vbNewLine & " We thank you for consulting our firm regarding your legal issue." & vbNewLine & vbNewLine & " Unfortunately, ..."
换句话说,当输入文本(而不是 HTML 格式的电子邮件)时,您需要 2 个 vbNewLines。
在后一种情况下:
"........" & _
"... more text ..."
等等。