Outlook 2007 中的 ItemSend 事件中的密件抄送不再起作用
我在 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 = "[email protected]"
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
I inserted code in ItemSend
and saved the ThisOutlookSession module. It worked once and no longer works. It was saved as VBAproject.OTM and is still there when I open the module after restarting 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 = "[email protected]"
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在项目的主题字段上使用 and if 语句
,或者如果您希望主题中包含单词,则使用
use and if statement on the Item's Subject field
or use if you want a contains a word in the subject
如果您要挂钩
ItemSend
事件,则该事件应该位于具有WithEvents
的类模块中,并且您的代码应在常规模块中调用它。此外,您还需要对邮件执行Item.Save
以便保留密件抄送。If you're hooking the
ItemSend
event, that should be in a class module withWithEvents
and your code to call it in a regular module. Also, you'll want to do anItem.Save
on the message for the BCC to stick.我最近遇到这个问题。它是在 .pst 文件以某种方式损坏后开始的,我必须运行 scanpst.exe (我必须搜索我的驱动器,因为错误消息没有告诉您它在哪里)
运行 scanpst.exe 并出现问题后本身,这就是我修复它的方法。
首先,我摆弄了宏观安全性。我把它设置为最低设置。 这是一个介绍如何更改宏安全性的链接。转到工具>宏>安全。我将其设置为“不对宏进行安全检查”。
然后我使用了这个确切的代码:
然后我单击“保存”按钮,然后单击绿色的小播放按钮来运行宏。它要求我提供一个宏名称。我使用 bccUsername 并单击“创建”。编辑器在
ThisOutLookSession
下添加了一个名为Modules
的部分。然后我重新启动 Outlook 并测试了两次,它成功了。
我不太确定我做了什么使它再次开始工作,但这与步骤不太相关,所以希望这可以帮助您和其他遇到同样问题的人。
I was having this issue recently. It started after the .pst file was corrupted in some way and I had to run scanpst.exe (which I had to search my drive for because the error message does not tell you where it is)
After running scanpst.exe and the issue presented itself, this is how I fixed it.
First, I fiddled with macro security. I set it to the lowest setting. Here is a link that covers how to change macro security. Go to Tools > Macro > Security. I set it to "No security check for Macros."
Then I used this exact code:
Then I clicked the save button then little green play button to run the macro. It asked me for a Macro name. I used bccUsername and clicked create. The editor added a section called
Modules
underThisOutLookSession
.I then restarted Outlook and tested twice and it worked.
I'm not exactly sure what I did that made it start working again, but this is not too involved with the steps so hopefully this helps you and others with the same problem.