我有一个 Outlook 脚本,它会显示收件人并提示用户“您确定要将此电子邮件发送给 XXX 吗?”但是,我们用于发送安全文件的插件存在问题,它会从脚本中提示用户两次而不是一次。他们告诉我循环遍历 items.Attachments 属性以检查以“.sf”结尾的文件名。如果包含此内容,则中止我的脚本。有人能告诉我怎么做吗?
Private Sub Application_ItemSend _ (ByVal Item As Object, Cancel As Boolean)
Dim strMsg As String
Dim Atmt As Variant
If Item.Class = "43" Then
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = ".sf" Then
GoTo NonEmailError
End If
Next Atmt
If Item.CC = "" Then
strMsg = "To recipients: " & Item.To & vbCrLf & _
"Are you sure you want to send this message?"
Else
strMsg = "To recipients: " & Item.To & vbCrLf & _
"Cc recipients: " & Item.CC & vbCrLf & _
"Bcc recipients: " & Item.BCC & vbCrLf & _
"Are you sure you want to send this message?"
End If
Else
GoTo NonEmailError
End If
On Error GoTo NonEmailError
NonEmailError:
' The item being sent was not an e-mail and so don't prompt the user anything
Exit Sub
End Sub
答案1
您需要For Each
在脚本中添加一个循环,循环遍历附件列表。如下所示。请注意,这是伪代码。我还没有尝试过:
For Each Atmt In item.Attachments
If Right(Atmt.FileName, 3) = ".sf" Then
-- Your code here
EndIf
Next Atmt