Outlook vba 怎么设置回复邮件的文本格式

m0_37171625 2017-11-21 09:54:59
下面的设置文本格式为纯文本设定了 之后好像没有用,请高手指点,还有这个方法之对应了【回复】按钮,请问【全部回复】也想添加的下面代码怎么改?


Option Explicit

Private WithEvents mItem As MailItem
Public WithEvents myExplorer As Explorer

' #########
' 析构函数.
' #########
Private Sub Class_Terminate()
If Not (mItem Is Nothing) Then
Set mItem = Nothing
End If

If Not (myExplorer Is Nothing) Then
Set myExplorer = Nothing
End If
End Sub

' #############################################################
' 事件: 当用户为项目 (父对象的一个实例) 选择 "答复" 动作时发生.
' #############################################################
Private Sub mItem_Reply(ByVal Response As Object, _
Cancel As Boolean)
'设置文本格式为纯文本
Response.BodyFormat = OlBodyFormat.olFormatPlain

MsgBox ("ok")

End Sub

' ##################################################
' 事件: 选择其他或更多 Microsoft Outlook 项目时发生.
' ##################################################
Private Sub myExplorer_SelectionChange()
Dim mySel As Selection

Set mySel = myExplorer.Selection

' /* 浏览器窗口中有且只有一个项目被选中. */
If mySel.Count = 1 Then
Dim objItem As Object

Set objItem = mySel.Item(1)

' /* 该选中项目是邮件. */
If objItem.Class = olMail Then
' /* 动态注册邮件的 Reply 事件. */
Set mItem = objItem
End If
End If

Set mySel = Nothing
Set objItem = Nothing
End Sub

' #####################################
' 强制触发浏览器窗口中的选中项改变事件.
' #####################################
Public Sub ForceSelectionChange()
Call myExplorer_SelectionChange
End Sub
...全文
1454 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
    Response.BodyFormat = OlBodyFormat.olFormatPlain
‘应改为
    Response.BodyFormat = 1 'CdoBodyFormatText    'Response.BodyFormat =OlBodyFormat.olFormatPlain
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
我一般只复制粘贴和问题有关的MSDN条文;而不真正回答问题。 我就是这么任性。
m0_37171625 2017-11-21
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
BodyFormat Property (CDONTS NewMail Object) The BodyFormat property sets the text format of the NewMail object. Write-only. Syntax objNewMail.BodyFormat Data Type Long Remarks BodyFormat can contain exactly one of the following values: BodyFormat setting Value Description CdoBodyFormatHTML 0 The Body property is to include Hypertext Markup Language (HTML). CdoBodyFormatText 1 The Body property is to be exclusively in plain text (default value). Example This code fragment shows the usage of the BodyFormat property in preparing and sending an HTML message: Dim myMail Set myMail = CreateObject("CDONTS.NewMail") HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL HTML = HTML & "<html>" HTML = HTML & "<head>" HTML = HTML & "<meta http-equiv=""Content-Type""" HTML = HTML & "HTML = HTML & ""content=""text/html; charset=iso-8859-1"">""" HTML = HTML & "<title>Sample NewMail</title>" HTML = HTML & "</head>" HTML = HTML & "<body>" HTML = HTML & "This is a sample message being sent using HTML. <BR></body>" HTML = HTML & "</html>" myMail.From = "Example@Microsoft.com" myMail.To = "Someone@Company.com" myMail.Subject = "Sample Message" myMail.BodyFormat = 0 myMail.MailFormat = 0 myMail.Body = HTML myMail.Send Set myMail = Nothing
感觉像是哪里复制过来的,并 没有真正回答我的问题
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
BodyFormat Property (CDONTS NewMail Object) The BodyFormat property sets the text format of the NewMail object. Write-only. Syntax objNewMail.BodyFormat Data Type Long Remarks BodyFormat can contain exactly one of the following values: BodyFormat setting Value Description CdoBodyFormatHTML 0 The Body property is to include Hypertext Markup Language (HTML). CdoBodyFormatText 1 The Body property is to be exclusively in plain text (default value). Example This code fragment shows the usage of the BodyFormat property in preparing and sending an HTML message: Dim myMail Set myMail = CreateObject("CDONTS.NewMail") HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL HTML = HTML & "<html>" HTML = HTML & "<head>" HTML = HTML & "<meta http-equiv=""Content-Type""" HTML = HTML & "HTML = HTML & ""content=""text/html; charset=iso-8859-1"">""" HTML = HTML & "<title>Sample NewMail</title>" HTML = HTML & "</head>" HTML = HTML & "<body>" HTML = HTML & "This is a sample message being sent using HTML. <BR></body>" HTML = HTML & "</html>" myMail.From = "Example@Microsoft.com" myMail.To = "Someone@Company.com" myMail.Subject = "Sample Message" myMail.BodyFormat = 0 myMail.MailFormat = 0 myMail.Body = HTML myMail.Send Set myMail = Nothing
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
Response.BodyFormat = 0 再试试看。
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
注释掉所有On Error Resume Next语句(如果有),在VBA IDE中运行, 出错后点击调试,光标会停在出错的那条语句处, 或者 事先在怀疑可能有逻辑错误的语句处设置断点,运行经过断点时中断, 此时可以在立即窗口中使用 ?变量名 或 ?函数名(函数参数) 或 过程名(参数) 辅助调试。
m0_37171625 2017-11-21
  • 打赏
  • 举报
回复
引用 5 楼 m0_37171625 的回复:
[quote=引用 4 楼 zhao4zhong1 的回复:]
    Response.BodyFormat = OlBodyFormat.olFormatPlain
‘应改为
Response.BodyFormat = 1 'CdoBodyFormatText 'Response.BodyFormat =OlBodyFormat.olFormatPlain


改过了,改完直接编译就报错了[/quote]
没报错但是还是没用
m0_37171625 2017-11-21
  • 打赏
  • 举报
回复
引用 4 楼 zhao4zhong1 的回复:
    Response.BodyFormat = OlBodyFormat.olFormatPlain
‘应改为
    Response.BodyFormat = 1 'CdoBodyFormatText    'Response.BodyFormat =OlBodyFormat.olFormatPlain
改过了,改完直接编译就报错了

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧