Excel VBA create Meeting in Non-Default Calendar

前端 未结 1 1181
我在风中等你
我在风中等你 2020-12-21 14:27

How do I create a Meeting on the non default calendar of the non default email address in outlook using VBA code?

The code that I have creates the invites in the def

相关标签:
1条回答
  • 2020-12-21 14:47

    This code will create a Appointment on non default calendar in a non default account in Outlook. Hope this helps someone else out in future:

    Sub Whatever()
    Dim olApp As Object
    Set olApp = GetObject(, "Outlook.Application")
    Dim oApt As Outlook.AppointmentItem
    Dim ns As Outlook.Namespace
    Dim recip As Outlook.Recipient
    Dim oFolder As Outlook.Folder
    Set ns = olApp.GetNamespace("MAPI")
    Set recip = ns.CreateRecipient("otheremail@contoso.com")
    
    If recip.Resolve Then
        Set otherFolder = ns.GetSharedDefaultFolder(recip, olFolderCalendar)
    End If
    
    Set oApt = otherFolder.Items.Add(olAppointmentItem)
    
    oApt.MeetingStatus = olMeeting
        With oApt
            .Subject = "Test"
            .Start = "15/04/2019 09:00"
            .End = "15/04/2019 09:10"
            .Location = "The Business Meeting Room"
            .Recipients.Add ("user@contoso.com")
            .Send
        End With
    End Sub
    
    0 讨论(0)
提交回复
热议问题