使用非默认响应自动响应弹出窗口

时间:2017-01-06 01:12:34

标签: vba outlook

我有一个VBA脚本,可以将所有传入的消息保存到Windows 7上的本地文件中。它已经运行了很长时间。

其中一位发件人开始以数字方式签署他们的邮件。现在,当脚本尝试保存邮件时,会弹出以下消息:

  

"您即将以不安全的格式保存经过数字签名的电子邮件。你想继续吗?"

按下两个按钮:是或否。否则是突出显示/默认响应。

格式是安全的,所以我并不担心。

以下内容不起作用:

Application.DisplayAlerts = False

因为默认答案是'否'。

我想自动点击“是”'。

我试图将发件人添加到我的联系人中,并且使用Outlook的安全设置进行修改无济于事。

Public Sub saveEmailtoDisk(itm As Outlook.MailItem)

    Dim saveFolder As String
    Dim rsaveFolder As String
    Dim vitolFolder As String
    Dim sName As String
    Dim from As String
    Dim fName As String
    sName = itm.Subject
    from = itm.SenderEmailAddress        

    If itm.Subject = "ReportName" Then
        Dim objAtt As Outlook.Attachments
        rsaveFolder = "D:\path\to\folder1\"
        Set objAtt = itm.Attachments
        objAtt.Item(1).SaveAsFile rsaveFolder & objAtt.Item(1).FileName '"ReportName - " & Format(itm.ReceivedTime, "yymmdd") & ".pdf"
    End If
    If InStr(from, "example.com") > 0 And itm.Attachments.Count > 0 Then
        Dim csvFile As Outlook.Attachments
        exampleFolder = "D:\path\to\folder2\"
        Set csvFile = itm.Attachments
        csvFile.Item(1).SaveAsFile exampleFolder & csvFile.Item(1).FileName
    End If
    saveFolder = "D:\path\to\folder3\"
    txtsaveFolder = "D:\path\to\folder4\"
    'MsgBox "-" & from & "-"
    ReplaceCharsForFileName sName, "_"
    itm.SaveAs saveFolder & Format$(itm.CreationTime, "yyyy-mm-dd") & "-" & sName & ".msg", olMSG
    itm.SaveAs txtsaveFolder & Format$(itm.CreationTime, "yyyy-mm-dd") & "-" & sName & ".txt", olTXT

    itm.UnRead = False

End Sub

Private Sub ReplaceCharsForFileName(sName As String, sChr As String)
    sName = Replace(sName, "/", sChr)
    sName = Replace(sName, "\", sChr)
    sName = Replace(sName, ":", sChr)
    sName = Replace(sName, "?", sChr)
    sName = Replace(sName, Chr(34), sChr)
    sName = Replace(sName, "<", sChr)
    sName = Replace(sName, ">", sChr)
    sName = Replace(sName, "|", sChr)
End Sub

0 个答案:

没有答案