本文介绍了在发送的每封电子邮件上设置 .SentOnBehalfofName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在通过 Outlook 2016 发送的每封电子邮件上设置 .SentOnBehalfOfName.也就是说,每当我点击新邮件、回复、全部回复或转发.
I am trying to set the .SentOnBehalfOfName on every email I send through Outlook 2016. That is, whenever I hit New Mail, Reply, Reply All, or Forward.
我试过了:
Public WithEvents myItem As Outlook.MailItem
Private Sub Application_ItemLoad(ByVal Item As Object)
If (TypeOf Item Is MailItem) Then
Set myItem = Item
End If
End Sub
Private Sub FromField()
With myItem
.SentOnBehalfOfName = "[email protected]"
.Display
End With
End Sub
Private Sub myItem_Open(Cancel As Boolean)
FromField
End Sub
推荐答案
In ThisOutlookSession
In ThisOutlookSession
Private WithEvents sentInsp As Inspectors
Private WithEvents sentMailItem As mailItem
Private Sub Application_Startup()
Set sentInsp = Application.Inspectors
End Sub
Private Sub sentInsp_NewInspector(ByVal Inspector As Inspector)
If Inspector.currentItem.Class = olMail Then
Set sentMailItem = Inspector.currentItem
sentMailItem.SentOnBehalfOfName = "[email protected]"
End If
End Sub
我发现必须通过每隔一段时间运行启动来重置我的事件代码.ItemSend 可能更可靠.
I have found my event code has to be reset by running startup at intervals. ItemSend may be more reliable.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim copiedItem As MailItem
If Item.Class = olMail Then
Set copiedItem = Item.Copy
copiedItem.SentOnBehalfOfName = "[email protected]"
'copiedItem.Display
copiedItem.Send
Item.Delete
Cancel = True
End If
Set copiedItem = Nothing
End Sub
当我运行此代码时,它不会再次调用 ItemSend.
When I run this code it does not call ItemSend again.
这篇关于在发送的每封电子邮件上设置 .SentOnBehalfofName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!