【问题标题】:How to determine if Outlook has any contacts如何确定 Outlook 是否有联系人
【发布时间】:2011-03-11 01:33:50
【问题描述】:

我有一个 VB.NET windows 应用程序,我在其中使用 Outlook 的联系人作为我的通讯录来获取电子邮件地址列表。我希望它使用 Outlook 作为通讯簿,但如果尚未设置 Outlook 邮箱或没有联系人,那么我根本不希望 Outlook 出现。我遇到的问题是,一旦我尝试访问 Outlook,Outlook 启动向导就会出现,这是我不希望发生的。这是我的代码:

Dim ao As Outlook.Application
Dim ons As Outlook.NameSpace
Dim Contacts As Outlook.Items

ao = New Outlook.Application
' The Outlook Startup Wizard comes up on this line of code.
ons = ao.GetNamespace("MAPI")

【问题讨论】:

  • @Luiscencio - 认为他的帖子可能需要 C# 或 VB.NET 作为其所有相同的 CLR。他正在寻找任何解决方案,甚至可以采用 C# 解决方案并进行转换。

标签: c# vb.net outlook


【解决方案1】:

您可以检查以下注册表项以查看 Outlook 是否已配置:

“HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Messaging Subsystem\Profiles”

以下代码示例演示了这一点:

Imports Microsoft.Win32

Module Module1

    Sub Main()
        Console.WriteLine("Outlook Profile Setup?:" + OutlookProfileExists().ToString())

        Console.ReadLine()
    End Sub

    Public Function OutlookProfileExists() As Boolean
        Dim rk As RegistryKey = Registry.CurrentUser
        Dim sk = rk.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles")

        Return sk.SubKeyCount > 0
    End Function
End Module

假设它已配置,然后正常启动并检查联系人列表。我无论如何都找不到在不启动它的情况下阅读联系人列表,但至少您可以验证它是否已配置。

【讨论】:

    猜你喜欢
    • 2011-06-16
    • 2020-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多