Disable Outlook Reply to All in Excel VBA

馋奶兔 提交于 2019-12-11 11:48:24

问题


i have a Excel VBA Macro that sends an email to multiple people. i don't want to hide who it has been sent to, i just want to disable the Reply to All function on outlook.

I have tried the below, from outlook VBA, and it had no effect

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

Here it is in the code.

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

Thanks


回答1:


Change .ActiveInspector to .GetInspector.

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



回答2:


Fixed It.

Need to display the Email first.

then .ActiveInspector.CurrentItem needs to be on Application not the item

so i used:

Set OutlMail = OutlApp.CreateItem(0)

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



回答3:


You don't have to display the item first. Change the code to

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


来源:https://stackoverflow.com/questions/32560831/disable-outlook-reply-to-all-in-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!