我正在尝试为通过 Outlook 2016 发送的每封电子邮件设置 .SentOnBehalfOfName。也就是说,每当我点击“新邮件”、“回复”、“全部回复”或“转发”时。
我试过这个:
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属性仅在 Exchange 配置文件/帐户的情况下才有意义。此外,您需要具有代表其他人发送所需的权限。参见 Issue with SentOnBehalfOfName进行类似的讨论。
如果您在配置文件中配置了多个帐户,您可以使用 SendUsingAccount允许一个帐户对象的属性,该对象表示要发送 MailItem 的帐户。
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
关于vba - 在每封发送的电子邮件上设置 .SentOnBehalfofName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33331320/