【问题标题】:Handling errors in Outlook Rule处理 Outlook 规则中的错误
【发布时间】:2020-06-21 07:33:41
【问题描述】:

我有一个触发时运行脚本的 Outlook 规则。它在 99% 的时间内都有效,但偶尔会出现“此操作失败”消息,然后该规则会自动停用并显示为红色。

我不确定这是由于 VBA 代码中的问题还是其他原因。

如果我们找不到解决方案,是否有可能以某种方式自动重新启用规则,或者在发生此错误时发送通知电子邮件 - 因为这发生在运行某些进程的“独立”PC 上,并且不会一直受到监控。

Public Sub Recon(itm As Outlook.MailItem)
Dim dt As String
dt = Format(CStr(Now), "yyyymmddhhmmss")
Dim Filepath1 As String
Filepath1 = "C:\Users\tenba1\Documents\QlikView\Account Recons\Queued\Recon_Acct_" & dt & ".txt"
Filepath2 = "C:\Users\tenba1\Documents\QlikView\Account Recons\Queued\Recon_SenderEmail_" & dt & ".txt"
Filepath3 = "C:\Users\tenba1\Documents\QlikView\Account Recons\Queued\Recon_SenderName_" & dt & ".txt"
Const ForWriting = 2

strAccNumber = Trim(Mid(itm.Subject, InStrRev(itm.Subject, " "), Len(itm.Subject) - InStr(1, itm.Subject, " ")))
strSender = itm.Sender.GetExchangeUser().PrimarySmtpAddress
strSenderName = itm.Sender

'Update the Account Number File:
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile(Filepath1)
oFile.WriteLine "SET vAcct = '" & strAccNumber & "';"
oFile.Close
Set fso = Nothing
Set oFile = Nothing

'Update the Sender Email Address File:
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile(Filepath2)
oFile.WriteLine strSender
oFile.Close
Set fso = Nothing
Set oFile = Nothing

'Update the Sender Name File:
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile(Filepath3)
oFile.WriteLine strSenderName
oFile.Close
Set fso = Nothing
Set oFile = Nothing

End Sub 

【问题讨论】:

  • 面临同样的问题,迁移到 NewMailEx 事件处理程序,从未回头。

标签: vba outlook


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多