Add recipient : Outlook Contact « Outlook « VBA / Excel / Access / Word






Add recipient

 

Public Sub AddRecipient()
    Dim oSelect As Outlook.SelectNamesDialog
    Dim colRecipients As Outlook.Recipients
    Dim oRecip As Outlook.Recipient
    Dim oMail As Outlook.MailItem
    
    Set oMail = Application.CreateItem(olMailItem)
    Set oSelect = Application.Session.GetSelectNamesDialog
    
    With oSelect
    .AllowMultipleSelection = False
            .SetDefaultDisplayMode OlDefaultSelectNamesDisplayMode.olDefaultMail
            .ForceResolution = True
            .Caption = "My Mail Selector Dialog"
            .ToLabel = "My To Selector"
            .NumberOfRecipientSelectors = OlRecipientSelectors.olShowTo
            .Display
            If .Recipients.Count = 1 Then
                Set oRecip = oMail.Recipients.Add(.Recipients.Item(1).Name)
            End If
    End With
    oMail.Display
End Sub

 








Related examples in the same category

1.Print all names from your contact list in Outlook
2.Add new contact item to Outlook
3.Delete a contact from Outlook
4.Create Outlook.Application
5.add a contact through VBA