0

我正在尝试通过 VBA 为 Outlook 2007 中的一组电子邮件检索 SMTP 地址。我需要来自发件人的完整 SMTP 地址。该地址主要来自 EXCHANGE 2007 服务器。

我有 smtp 地址 test@something.co.uk;test1@something.co.uk; test3@somthing.co.uk 在另一个表中查看电子邮件地址到另一个字段。

我需要使用电子邮件中的 SMTP 地址来查找该字段。

执行 storename = mItem.SenderEmailAddress 时,我得到一个 x400 地址,但我需要 SMTP 地址。当然有办法解决这个问题。我不想使用赎回。我希望有人可以为此提供答案。

谢谢H

4

1 回答 1

0

试试下面的代码,虽然在 2010 年忙着使用

Sub Test()
Dim appOutlook As Outlook.Application
Dim nsOutlook As Outlook.Namespace
Dim cfOutlook As Outlook.Folder
Dim ifOutlook As Outlook.Folder
Dim x  As Long
Dim y As Long

'Create a new instance of the Outlook application.
'Set the Application object as follows:
Set appOutlook = New Outlook.Application

'use the GetNameSpace method to instantiate (ie. create an instance)
'a NameSpace object variable, to access existing Outlook items.
'Set the NameSpace object as follows:
Set nsOutlook = appOutlook.GetNamespace("MAPI")

'assign the object variable cfOutlook to the default Contacts folder:
Set cfOutlook = nsOutlook.GetDefaultFolder(olFolderContacts)
MsgBox cfOutlook

'assign the object variable ifOutlook to the default Inbox folder:
Set ifOutlook = nsOutlook.GetDefaultFolder(olFolderInbox)
MsgBox ifOutlook


y = nsOutlook.Accounts.Count
MsgBox y

For x = 1 To y
MsgBox nsOutlook.Accounts(x)
MsgBox nsOutlook.Accounts.Item(x).SmtpAddress
Next x

End Sub
于 2013-03-17T09:16:47.423 回答