How to access contact groups in Excel VBA?

前端 未结 2 1700
误落风尘
误落风尘 2021-01-17 23:59

I am building an Excel add-in that sends the active workbook as an attachment in an Outlook email template to a specific Contact Group.

I\'ve gotten the first two pa

2条回答
  •  有刺的猬
    2021-01-18 00:43

    In order to have the recipient's email addresses or names resolved (so they don't display just plain text), you can do the following.

    With OutMail
        '.TO field should be set to the contact group
        .BCC = ""
        .Attachments.Add ActiveWorkbook.FullName
        .HTMLBody = Replace(OutMail.HTMLBody, strOldPeriod, strNewPeriod)
        .Subject = Replace(OutMail.Subject, strOldPeriod, strNewPeriod)
        'To display the email leave as is;  to send the Email, change to .Send
        .Display    'or Send
        If Not .Recipients.ResolveAll Then
            For Each Recipient In .Recipients
                If Not Recipient.Resolved Then
                    MsgBox Recipient.Name & " could not be resolved"
                End If
            Next 
        End If
    End With
    

提交回复
热议问题