如何检索发件人的电子邮件地址
我已经在Outlook 2013中编写了一个宏,我需要在其中以字符串的形式检索发件人的电子邮件地址
I've written a Macro in Outlook 2013 where I need to retrieve the sender email address as a string
一个简单的版本是
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oMail As MailItem
Set oMail = Item
Dim sender as String
sender = oMail.SenderEmailAddress
End Sub
以上效果很好.
我现在已经向Outlook添加了一个新的电子邮件帐户,这就是问题所在.
I now have added a new email account to Outlook and this is where the issue is.
如果创建新电子邮件,它将使用我的default@mail.com电子邮件地址.然后,如果我更改了发送电子邮件的帐户(发送到myOtherAccount@mail.com),则VBa中的SenderEmailAddress不会反映此更改...它仍然(在监视窗口中)显示为default.mail.com.
If I create a new email it uses my default@mail.com email address. If I then change the account from which to send the email from (to myOtherAccount@mail.com), the SenderEmailAddress within the VBa does not reflect this change... It still shows (in the watch window) as default.mail.com
如何让Outlook重新检查发件人(因为我假设它已将其缓存在某些地方)?
How can I get Outlook to re-check the sender (as I assume it's caching it some where)?
所有发件人相关的属性均在 触发ItemSend事件后设置.第一次看到发件人属性是在已发送邮件"文件夹上触发Items.ItemAdd事件时.
All sender related properties are set after the ItemSend event fires. The first time you can see sender properties is when the Items.ItemAdd event fires on the Sent Items folder.