Outlook VBA。实施.SentOnBehalfOfName到我的代码
问题描述:
我有我的代码是这样的:Outlook VBA。实施.SentOnBehalfOfName到我的代码
Public WithEvents myItem As Outlook.MailItem
Private Sub Application_ItemLoad(ByVal Item As Object)
If Item.Class = olMail Then
Set myItem = Item
End If
End Sub
Private Sub myItem_Open(Cancel As Boolean)
Dim oAccount As Outlook.Explorer
Dim oMail As MailItem
Dim Recip As Outlook.Recipient
Set oAccount = Application.ActiveExplorer
MsgBox (oAccount.CurrentFolder.Store)
If oAccount.CurrentFolder.Store = "[email protected]" Then
MsgBox ("CC needs to be added")
Set Recip = myItem.Recipients.Add("[email protected]")
Recip.Type = olCC
Recip.Resolve
Else
MsgBox ("no need to add CC")
End If
End Sub
我想补充像myItem.SentOnBehalfOfName =“[email protected]”到我的代码,而只是将其粘贴到我的代码不起作用。我是编码技术人员,所以可能我必须先设置一些东西。任何人都可以帮助我这个?
我一直在寻找几个小时。我已经尝试了myItem.SentOnBehalfOfName =“[email protected]”,但它实际上什么都不做。它也没有显示任何错误,所以我不知道什么可能是错的。任何人都有线索?
答
这个棘手的SentOnBehalfOfName行为在前面的文章中有描述。
Private Sub myItem_Open_SentonBehalf_Test()
Dim oExpl As Explorer
Dim myItem As mailitem
Set oExpl = ActiveExplorer
Set myItem = CreateItem(olMailItem)
' Do not display
If oExpl.CurrentFolder.store = "[email protected]" Then
Debug.Print "myItem.SentOnBehalfOfName:" & "x " & myItem.SentOnBehalfOfName & " x"
myItem.SentOnBehalfOfName = "[email protected]"
Debug.Print "myItem.SentOnBehalfOfName:" & "x " & myItem.SentOnBehalfOfName & " x"
' be careful to put this after updating SentOnBehalfOfName
myItem.Display
' Manually display the From field to see the updated entry
Else
Debug.Print "Wrong path."
End If
ExitRoutine:
Set myItem = Nothing
Set oExpl = Nothing
End Sub
先搜索。基于该搜索,将myItem.SentOnBehalfOfName =“[email protected]”放入您的代码中,如果有问题,则询问有关问题。 – niton
我一直在寻找几个小时。我已经尝试了myItem.SentOnBehalfOfName =“[email protected]”,但它实际上什么都不做。它也没有显示任何错误,所以我不知道什么可能是错的。任何人都有线索? – Art