Wie greife ich in Excel VBA auf Kontaktgruppen zu?

Ich erstelle ein Excel-Add-In, mit dem die aktive Arbeitsmappe als Anhang in einer Outlook-E-Mail-Vorlage an eine bestimmte Kontaktgruppe gesendet wird.

Ich habe die ersten beiden Teile mit dem folgenden Code arbeiten lassen, bin mir aber nicht sicher, wie ich den einstellen soll.TO Feld an eine Kontaktgruppe.

<code>Public Sub Mail_Reports()
    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object 

    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    On Error Resume Next

    Set OutApp = CreateObject("Outlook.Application")

    'Set this line to the path and file name of your template
    Set OutMail = OutApp.CreateItemFromTemplate("C:\Users\moses\AppData\Roaming\Microsoft\Templates\test.oft")
    On Error Resume Next

    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
    End With

    On Error GoTo 0

    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
</code>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage