我正在从 Outlook 获取所有电子邮件地址的列表。以下代码有效。但是在大约 320 个结果之后,它会间歇性地给我以下错误。我得到一个 COM 异常。Microsoft Exchange 似乎无法处理该请求
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147467259
HResult=-2147467259
Message=The operation failed.
Source=Microsoft Outlook
我不能添加一个 try catch 块,因为它说异常有什么办法可以解决这个 Com 错误
Dim oApp As New Outlook.Application
Dim dal As AddressList
dal = oApp.Session.GetGlobalAddressList()
Dim addressentry As Outlook.AddressEntry
Dim d As Outlook.ExchangeUser
If Not dal Is Nothing Then
For index = 1 To dal.AddressEntries.Count - 1 Step 1
addressentry = dal.AddressEntries(index)
If addressentry.AddressEntryUserType = OlAddressEntryUserType.olExchangeUserAddressEntry Then
d = addressentry.GetExchangeUser()
Console.WriteLine("Count{0} ", index.ToString())
Console.WriteLine(String.Format("Name{0} email{1}", addressentry.Name, d.PrimarySmtpAddress))
End If
Next
End If
Console.ReadLine()