Returns a Links collection of Link objects that represent the contacts to which the item is linked.
expression.Links
expression Required. An expression that returns one of the objects in the Applies To list.
Example
This Microsoft Visual Basic/Visual Basic for Applications (VBA) example steps through the items in the Tasks folder and, if a task is not complete, displays the number of contacts linked to the item.
Sub CountLinks()
Dim myOlApp As New Outlook.Application
Dim myNSpace As Outlook.NameSpace
Dim myItems As Outlook.Items
Dim myItem As Outlook.TaskItem
Dim myLinks As Outlook.Links
Dim myLink As Outlook.Link
Dim x As Integer
Dim msg As String
Set myNSpace = myOlApp.GetNamespace("MAPI")
Set myItems = myNSpace.GetDefaultFolder(olFolderTasks).Items
For x = 1 To myItems.Count
If TypeName(myItems.Item(x)) = "TaskItem" Then
Set myItem = myItems.Item(x)
Set myLinks = myItem.Links
Msg = myItem.Subject & " has " & myLinks.Count & " links."
If myItem.Complete = False Then
If MsgBox(Msg, vbOKCancel) = vbCancel Then Exit For
End If
End If
Next x
End Sub
If you use Microsoft Visual Basic Scripting Edition (VBScript) in a Microsoft Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.
Set myNSpace = Application.GetNamespace("MAPI")
Set myItems = myNSpace.GetDefaultFolder(13).Items
For x = 1 To myItems.Count
If TypeName(myItems.Item(x)) = "TaskItem" Then
Set myItem = myItems.Item(x)
Set myLinks = myItem.Links
Msg = myItem.Subject & " has " & myLinks.Count & " links."
If myItem.Complete = False Then
If MsgBox(Msg, 1) = 2 Then Exit For
End If
End If
Next