使用 Outlook VBA 获取 item.recipient [英] Get item.recipient with Outlook VBA

查看:14
本文介绍了使用 Outlook VBA 获取 item.recipient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 Outlook 2010 上的项目中获取收件人电子邮件地址.

I need to get the recipient email address out of an item on Outlook 2010.

我的代码如下:

sSQL = "SELECT id from dbo.database where email_address LIKE '" & Item.RecipientEmailAddress & "'

item.recipientEmailAddress 无效,但我需要类似的东西.

item.recipientEmailAddress is not valid, but I need something like that.

我知道您有一个代码调用 Item.SenderEmailAddress 但在这种情况下我需要收件人的电子邮件地址.

I know that you have a code call Item.SenderEmailAddress but in this case I need the recipient's email address.

我已经看到了有关该主题的其他一些主题,但我没有设法使它们中的任何一个起作用.

I've seen some other threads on that subject but I did not manage to make any of them work.

推荐答案

为了快速"执行此操作,您可以将 Item.ToItem.CC 连接在一起Item.BCC 属性,但是,这可能不是您要查找的内容,因为有时这些属性存储显示名称而不是 SMTP 电子邮件地址.

For a "quick" way of doing it, you can concatenate the Item.To together with the Item.CC and Item.BCC properties, however, this may not be what you're looking for as sometimes these properties store the display names instead of the SMTP email addresses.

另一种方法是使用 Item.Recipients 集合,其中包含一个 Recipient 对象,其中包含每个收件人(收件人、抄送和密件抄送)的 Address 属性.

Another way is to use the Item.Recipients collection which contains a Recipient object, which contains an Address property, for every recipient (TO, CC, and BCC).

您可以遍历每个收件人并将它们连接在一起.像这样:

You could loop through each recipient and concatenate them together. Something like this:

Dim recip As Recipient
Dim allRecips As String

For Each recip In item.Recipients
    If (Len(allRecips) > 0) Then allRecips = allRecips & "; "
    allRecips = allRecips & recip.Address
Next

这篇关于使用 Outlook VBA 获取 item.recipient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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