【Excel VBA】Outlookの自分のメールアドレスを取得する方法

【Excel VBA】Outlookのメールアドレスを取得する方法

Excel VBAでOutlookでログインしているメールアドレスを取得する方法をご紹介します。

目次 非表示

実際のコード

早速ですが、実際のコードはこちらです。

Excel VBA
Sub mailaddres() Dim OL, olAllUsers, oExchUser, oentry, myitem As Object Dim User As String Set OL = CreateObject("outlook.application") Set olAllUsers = OL.Session.AddressLists.Item("All Users").AddressEntries User = OL.Session.CurrentUser.Name Set oentry = olAllUsers.Item(User) Set oExchUser = oentry.GetExchangeUser() MsgBox oExchUser.PrimarySmtpAddress
End Sub

参考

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA