Export (0) Print
Expand All
Expand Minimize

TaskItem.Links Property (Outlook)

Office 2010

Returns a Links collection that represents the contacts to which the item is linked. Read-only.

expression .Links

expression A variable that represents a TaskItem object.

This Microsoft 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 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 = Application.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
Show:
© 2015 Microsoft