如何检索发件人的电子邮件地址 [英] How to retrieve the sender email address

查看:114
本文介绍了如何检索发件人的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在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.

这篇关于如何检索发件人的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆