D
Don
Using VS 2005 and VB.NET. In the sample code below, GetFirst returns an Item
Object, but it's wrapped in the System.__ComObject type. When I try to use
CType to get a MailItem object, I get the error "No Such Interface
Supported". And if I try to use lobjItem properties directly, such as
lobjItem.Subject, I get the error "Option Strict On disallows late binding".
Anyone have a solution for this? Thanks!
Dim lobjFolder As Outlook.MAPIFolder = Nothing
Dim lobjFolderItems As Outlook.Items = Nothing
Dim lobjFolders As Outlook.Folders = Nothing
Dim lobjMI As Outlook.MailItem = Nothing
Dim lobjItem As Object = Nothing
Dim lstrTypeName as String = ""
Dim lstrSubject as String = ""
'---more code before this
If lobjFolders.Count > 0 Then
lobjFolder = lobjFolders.Item(1)
lobjFolderItems = lobjFolder.Items
lobjItem = lobjFolderItems.GetFirst
lstrTypeName = TypeName(lobjItem).ToUpper
If lstrTypeName = "MAILITEM" Then
lobjMI = CType(lobjItem, Outlook.MailItem)
lstrSubject = lobjMI.Subject.Trim
'---more code...
End If
End If
Object, but it's wrapped in the System.__ComObject type. When I try to use
CType to get a MailItem object, I get the error "No Such Interface
Supported". And if I try to use lobjItem properties directly, such as
lobjItem.Subject, I get the error "Option Strict On disallows late binding".
Anyone have a solution for this? Thanks!
Dim lobjFolder As Outlook.MAPIFolder = Nothing
Dim lobjFolderItems As Outlook.Items = Nothing
Dim lobjFolders As Outlook.Folders = Nothing
Dim lobjMI As Outlook.MailItem = Nothing
Dim lobjItem As Object = Nothing
Dim lstrTypeName as String = ""
Dim lstrSubject as String = ""
'---more code before this
If lobjFolders.Count > 0 Then
lobjFolder = lobjFolders.Item(1)
lobjFolderItems = lobjFolder.Items
lobjItem = lobjFolderItems.GetFirst
lstrTypeName = TypeName(lobjItem).ToUpper
If lstrTypeName = "MAILITEM" Then
lobjMI = CType(lobjItem, Outlook.MailItem)
lstrSubject = lobjMI.Subject.Trim
'---more code...
End If
End If