gpt4 book ai didi

vba - Outlook 2007 中的 ItemSend 事件中的密件抄送不再有效

转载 作者:行者123 更新时间:2023-12-04 19:22:22 25 4
gpt4 key购买 nike

我在 ItemSend 中插入了代码并保存了 ThisOutlookSession 模块。它工作了一次,不再工作。它被保存为 VBAproject.OTM 并且在我重新启动 Outlook 后打开模块时仍然存在。

Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next

''# #### USER OPTIONS ####
''# address for Bcc -- must be SMTP address or resolvable
''# to a name in the address book
strBcc = "someone@somewhere.dom"

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If

Set objRecip = Nothing
End Sub

最佳答案

在项目的主题字段上使用和 if 语句

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "exact match" Then

strBcc = "someone@somewhere.dom"

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If


End If
Item.Save

Set objRecip = Nothing


End If

或者如果你想在主题中包含一个单词,请使用
If InStr(Item.Subject, "BCCSubject") = 0 Then


End If

关于vba - Outlook 2007 中的 ItemSend 事件中的密件抄送不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2522884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com