Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何确定Outlook是否有联系人_C#_Vb.net_Outlook - Fatal编程技术网

C# 如何确定Outlook是否有联系人

C# 如何确定Outlook是否有联系人,c#,vb.net,outlook,C#,Vb.net,Outlook,我有一个VB.NET windows应用程序,其中我使用Outlook的联系人作为通讯簿来获取电子邮件地址列表。我希望它使用Outlook作为通讯簿,但如果Outlook邮箱尚未设置或没有联系人,则我根本不希望Outlook出现。我遇到的问题是,只要我尝试访问Outlook,Outlook启动向导就会出现,我不希望出现这种情况。这是我的密码: Dim ao As Outlook.Application Dim ons As Outlook.NameSpace Dim Contacts As Ou

我有一个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")

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

“HKEY\U当前\U用户\软件\ 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

假设已配置,然后像正常一样启动并检查联系人列表。我无法在不启动联系人列表的情况下读取联系人列表,但至少您可以验证它是否已配置。

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

“HKEY\U当前\U用户\软件\ 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

假设已配置,然后像正常一样启动并检查联系人列表。我无法在不启动联系人列表的情况下阅读联系人列表,但至少你可以验证它是否已配置。

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