Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 如何从Outlook中删除发件人发送的邮件项目_Vba_Excel_Email_Outlook - Fatal编程技术网

Vba 如何从Outlook中删除发件人发送的邮件项目

Vba 如何从Outlook中删除发件人发送的邮件项目,vba,excel,email,outlook,Vba,Excel,Email,Outlook,以下Excel to VBA代码删除发件人邮件时出现运行时错误 Sub Worksheet_Change(ByVal Target As Range) Dim PriorVal As String ' For the worksheet AuditLog With Sheets("AuditLog") If Selection(1).Value = "" Then PriorVal =

以下Excel to VBA代码删除发件人邮件时出现运行时错误

        Sub Worksheet_Change(ByVal Target As Range)
        Dim PriorVal As String
' For the worksheet AuditLog        
        With Sheets("AuditLog")
        If Selection(1).Value = "" Then
                PriorVal = "Blank"
            Else
                PriorVal = Selection(1).Value
            End If
        Set OutlookApp = CreateObject("Outlook.Application")
        Set OlObjects = OutlookApp.GetNamespace("MAPI")
        Set newmsg = OutlookApp.CreateItem(olMailItem)
        'add recipients
        newmsg.Recipients.Add ("add your mail id")
        'add subject
        newmsg.Subject = ("AuditLog has a violator") '"," Environ("UserName"), Environ("ComputerName"), & sh.Name "
        'add body
        newmsg.Body = Application.UserName & " has made changes to the AuditLog _ tab at cell position " & Target(1).Address & ", " & Target(1).Value
        newmsg.Display 'display
        newmsg.Send 'send message
        newmsg.DeleteAfterSubmit = True
        End With
            Set newmsg = Nothing:     Set OutlookApp = Nothing:
        End Sub
把这些换一下

newmsg.DeleteAfterSubmit = True
newmsg.Send 'send message
把这些换一下

newmsg.DeleteAfterSubmit = True
newmsg.Send 'send message

除了@mrbungle所写的以外,根据经验,一旦调用Send,唯一允许的操作就是取消对消息的引用-它现在属于假脱机程序


也没有理由在消息仍在显示时调用Display(无模式)然后发送。如果您正在显示消息,是否不希望用户单击“发送”按钮?

除了@mrbungle所写的以外,根据经验,一旦您调用“发送”,唯一允许的操作就是取消对消息的引用-它现在属于假脱机程序


也没有理由在消息仍在显示时调用Display(无模式)然后发送。如果您正在显示邮件,是否希望用户单击“发送”按钮?

您好,Dmitry,我希望邮件应该发送,但不希望他知道有邮件触发器发送给他的主管,因为跟踪将在“已发送项目”下可用。不要调用Display,将DeleteAfterSubmit属性设置为true,调用Send。我已按建议更改了代码,您是对的。您好Dmitry,我希望邮件应该发送,但他违反了AuditLog选项卡,但不希望他知道有邮件触发器发送给他的主管,因为跟踪将在Sent Items下可用。不要调用Display,将DeleteAfterSubmit属性设置为true,调用Send。我已按照建议更改了代码,您是对的。您好Bungle先生,我已尝试过此操作,但邮件仍在Send项下可用,只有一个例外。谢谢你好,Bungle先生,我已经尝试过了,但是邮件仍然可以在“已发送邮件”下使用,只有一个例外。谢谢