在每封发送的电子邮件上设置.SentOnBehalfofName [英] Set .SentOnBehalfofName on every email sent
问题描述
我试图在通过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 = "example@aol.com"
.Display
End With
End Sub
Private Sub myItem_Open(Cancel As Boolean)
FromField
End Sub
推荐答案
有关SentOnBehalfOfName的问题,以进行类似的讨论.
The SentOnBehalfOfName property makes sense only in case of Exchange profiles/accounts. Moreover, you need to have the required permissions to send on behalf of another person. See Issue with SentOnBehalfOfName for a similar discussion.
In case if you have multiple accounts configured in the profile you can use the SendUsingAccount property which allows to an Account object that represents the account under which the MailItem is to be sent.
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("someone@example.com")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
这篇关于在每封发送的电子邮件上设置.SentOnBehalfofName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!