我有一個 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