0

Outlook 2007 で一連の電子メールの SMTP アドレスを VBA 経由で取得しようとしています。送信者から完全な 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

以下のコードを試してみてください.

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 に答える