我经常想要更改当前打开的Mail中的发件人数据 这可以通过以下代码完成:
Sub AktiveMailSetVonHotline()
Dim oMail As Outlook.MailItem
Set oMail = ActiveInspector.CurrentItem
oMail.SentOnBehalfOfName = "Hotline@mycompany.de"
End Sub`
唯一的问题/缺点是: 运行该宏后,我看不到发件人是否按需设置。为此,我想刷新可见的邮件(检查窗口)
答案 0 :(得分:1)
要使From标签显示正确的值,您需要使用MailItem.PropertyAccessor.SetProperty设置PR_SENT_REPRESENTING_EMAIL_ADDRESS属性(DASL名称http://schemas.microsoft.com/mapi/proptag/0x0065001F
)。
<强>更新强>
作为测试,您可以尝试从OutlookSpy运行以下脚本 - 在Outlook中创建新邮件,单击&#34;脚本&#34;消息检查器中OutlookSpy功能区上的按钮,粘贴下面的脚本,单击运行:
set Msg = Application.ActiveInspector.CurrentItem
Msg.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x0065001F", "another@user.demo"
答案 1 :(得分:0)
看起来您对MailItem类的SendUsingAccount属性感兴趣,该属性允许设置一个Account对象,该对象表示要在其下发送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