[英]Reference Outlook Account by email address
I have found the following VBA, which I'm using in excel VBA, which will return each Outlook account item and its account number.我找到了以下 VBA,我在 excel VBA 中使用它,它将返回每个 Outlook 帐户项目及其帐号。
Sub Which_Account_Number()
Dim OutApp As Outlook.Application
Dim I As Long
Set OutApp = CreateObject("Outlook.Application")
For I = 1 To OutApp.Session.Accounts.Count
MsgBox OutApp.Session.Accounts.Item(I) & " : This is account number " & I
Next I
End Sub
I want to select the account number that is associated to a specific from email address, instead of returning them all one after another.我想选择与特定电子邮件地址相关联的帐号,而不是一个接一个地返回它们。
You just need to set it directly你只需要直接设置
Sub Which_Account_Number()
Dim OutApp As Outlook.Application
Dim DesiredAccount As Outlook.Account
Set OutApp = CreateObject("Outlook.Application")
Set DesiredAccount = OutApp.Session.Accounts.Item("desiredemail@domain.com")
MsgBox DesiredAccount.DisplayName
Set DesiredAccount = Nothing
Set OutApp = Nothing
End Sub
Probably this and this may be helpful as well later on.可能 这和 这可能对以后也有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.