我想检测的投票按钮,并通过VBA的核可。我可以选择邮件,但我不能发现在的MailItem类的任何方法来检测或投票按钮的批准。我对我的选择目前电子邮件的代码
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim obj As MailItem
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
Set obj = myOlSel.Item(1)
我找不到在的MailItem类的任何方法来检测
所述的MailItem对象具有由分号分隔的一个.VotingOptions
属性(字符串),例如,“批准;拒绝”或“是的,否”等
任何非空字符串,应说明投票按钮的存在。
你表明你想“的表决按钮的批准” - 这是什么意思?有一些标准的响应类型,但也可能是一个自定义的响应(S)。您无法自动处理任何潜在组响应,即使你知道组响应,你如何“自动”批准/拒绝或有/无回复 - 除非您已经阅读并了解他们在做什么请您投票?
因此,我认为这不是一个好办法,但这里是使用的方法:
If TypeName(obj) = "MailItem" And obj.VotingOptions <> vbNullString Then
obj.VotingResponse = "Yes"
End If
要检查你的“默认”的响应是否是一个有效的响应(响应无效不会出现当我测试他们提高错误):
Dim defaultResponse as String
Dim resp as String
defaultResponse = "Approve"
If TypeName(obj) = "MailItem" And obj.VotingOptions <> vbNullString Then
For each resp in Split(obj.VotingOptions, ";")
if resp = defaultResponse Then
obj.VotingResponse = "Yes"
Exit For
End If
Next
End If
你可以在逻辑当然扩大到覆盖不同的场景,等等。
“编辑回应”你可以这样做:
Dim m As MailItem
Set m = obj.Reply 'or obj.ReplyAll
m.Body = "Insert your response here!" '## Modify as needed
m.Display 'optional
m.Save
m.Send
我能做到这一点使用此代码:
Sub SendEmail()
Dim myOlExp As Outlook.Explorer
Dim hk() As String
Dim myOlSel As Outlook.Selection
Dim obj As MailItem
Dim obj2 As Outlook.MailItem
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection
Set obj = myOlSel.Item(1)
For Each MA In obj.Actions
If MA.Name = "Approved" Then
Set obj2 = Ma.Execute
obj.Body = "My Message"
obj.Send
Exit For
End If
Next MA
End Sub