在Excel VBA中禁用Outlook回复全部

时间:2015-09-14 08:59:48

标签: excel vba excel-vba outlook outlook-vba

我有一个Excel VBA宏,可以向多人发送电子邮件。我不想隐藏它被发送给谁,我只想禁用outlook上的全部回复功能。

我在Outlook VBA中试过了以下内容,但没有效果

ActiveInspector.CurrentItem.Actions("Reply to All").Enabled = False 
ActiveInspector.CurrentItem.Actions("Forward").Enabled = False

这是在代码中。

Set OutlMail = OutlApp.CreateItem(0)
On Error Resume Next
With OutlMail
    .To = sendto
    .Subject = "Update for: " & Date
    Set rng = Workbooks("UpdateV2.xlsm").Sheets("EmailP").Range("A1:S75")
    Call SortAbs
    Workbooks("UpdateV2.xlsm").Sheets("EmailP").Calculate

    .ActiveInspector.CurrentItem.Actions("Reply to All").Enabled = False 
    .ActiveInspector.CurrentItem.Actions("Forward").Enabled = False

    .htmlbody = "<body style=font-size:11pt;font-family:Arial bgcolor='#FBEDD4'>" & _

    "Please note that this email is Confidential. Do not forward." & _
    "<BR><BR> <i> This is an Automatic Email - Generated by: " & GetUserFullName & "</i> <BR><BR></body>" & RangetoHTML(rng)

    .Display
 End With
On Error GoTo 0
Set OutlMail = Nothing

由于

3 个答案:

答案 0 :(得分:0)

将.ActiveInspector更改为.GetInspector。

.GetInspector.CurrentItem.Actions("Reply to All").Enabled = False
.GetInspector.CurrentItem.Actions("Forward").Enabled = False

答案 1 :(得分:0)

修正了它。

首先需要显示电子邮件。

然后.ActiveInspector.CurrentItem需要在Application而不是项目

所以我用过:

Set OutlMail = OutlApp.CreateItem(0)

.Display
'.......
End With
outlapp.ActiveInspector.CurrentItem.Actions("Reply to All").Enabled = False 
outlapp.ActiveInspector.CurrentItem.Actions("Forward").Enabled = False

答案 2 :(得分:0)

您不必先显示该项目。将代码更改为

OutlMail.Actions("Reply to All").Enabled = False 
OutlMail.Actions("Forward").Enabled = False