使用VBA创建Outlook会议

时间:2019-05-02 23:49:15

标签: excel vba outlook

我有一个UserForm,它在完成并用户选中发送会议邀请的框后应创建一个Outlook会议邀请。不是活动或约会!该代码工作正常,但它是作为约会而不是会议打开的。我已经搜索并尝试了很多东西,但是很困惑。

如果formAdd.checkCalendar.Value = True然后

    Dim ObjOutlook As Object
    Dim ObjMeeting As Object

    Set ObjOutlook = CreateObject("Outlook.Application")
    Set ObjMeeting = ObjOutlook.CreateItem(1)

    ObjOutlook.Session.Logon
    ObjMeeting.Display
    On Error Resume Next

    With ObjMeeting
        .Subject = comboCustomer.Value & " " & comboYear.Value & " " & comboProject.Value & " " & "Bulletin" & " " & txtBulletin.Value & " " & "Review Due!"
        .RequiredAttendees = IIf(IsNull(comboA.Value) = 0 And Trim(comboA.Value) <> "", Replace(comboA.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboB.Value) = 0 And Trim(comboB.Value) <> "", Replace(comboB.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboC.Value) = 0 And Trim(comboC.Value) <> "", Replace(comboC.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboD.Value) = 0 And Trim(comboD.Value) <> "", Replace(comboD.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboE.Value) = 0 And Trim(comboE.Value) <> "", Replace(comboE.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboF.Value) = 0 And Trim(comboF.Value) <> "", Replace(comboF.Value, " ", ".") & "@xyz.com" & "; ", "") & _
                             IIf(IsNull(comboG.Value) = 0 And Trim(comboG.Value) <> "", Replace(comboG.Value, " ", ".") & "@xyz.com" & "; ", "")
        .Body = "Enter Body of Meeting Here"
        .Start = txtReviewDate.Value & " " & TimeValue("8:00 AM")
        .Duration = 15
        .ReminderSet = True
        .BusyStatus = 0 'olfree
        .ReminderMinutesBeforeStart = "1440"

    End With
End If

2 个答案:

答案 0 :(得分:0)

试试这个

Dim ObjMeeting As Outlook.AppointmentItem

然后 这里的myapp是应用程序的应用程序名称,例如

Set myapp = New Outlook.Application
Set ObjMeeting = myapp.CreateItem(olAppointmentItem)

在代码末尾也应该

End With
CreateAppointment = True

答案 1 :(得分:0)

我想我明白了。通过添加.Meeting = 1,它将约会更改为会议

使用ObjMeeting

    .Meeting = 1
    .Subject = comboCustomer.Value & " " & comboYear.Value & " " & comboProject.Value & " " & "Bulletin" & " " & txtBulletin.Value & " " & "Review Due!"
    .RequiredAttendees = IIf(IsNull(comboA.Value) = 0 And Trim(comboA.Value) <> "", Replace(comboA.Value, " ", ".") & "@xyz.com" & "; ", "") & _
    .Body = "Enter Body of Meeting Here"
    .Start = txtReviewDate.Value & " " & TimeValue("8:00 AM")
    .Duration = 15
    .ReminderSet = True
    .BusyStatus = 0 'olfree
    .ReminderMinutesBeforeStart = "1440"
End With