如何以编程方式访问Outlook约会中表的内容

时间:2016-05-04 17:42:37

标签: vba excel-vba outlook-vba rtf excel

我正在开发一个项目,我需要以某种方式以编程方式访问Outlook邀请中嵌入的表的内容。如果是在电子邮件中,我将处理“MailItem”类的对象,我可以调用HTMLBody并使用“table”标签来获取内容。但是,据我所知,“AppointmentItem”对象不存在类似的功能。我知道MailItems有“RTFBody”功能,但我完全不知道如何使用RTF获取表格的内容,谷歌在这方面不是很有帮助。出于我的目的,Outlook邀请中的表可以是嵌入式Excel工作表对象,也可以只是通过转到“插入”|“插入”来插入的表。表

我的最终目标是将表格内容嵌入共享团队日历中并将其发送到Excel工作表,我在其中构建了我的团队所拥有的会议仪表板。在团队日历上的Outlook邀请中嵌入的表的内容具有我希望在仪表板中动态显示的数据点。

任何帮助都会非常感激,非常感谢 - 谢谢!

1 个答案:

答案 0 :(得分:0)

你能试试吗?

Private Sub Add_Appointments_To_Outlook_Calendar()

    'Include Microsoft Outlook nn.nn Object Library from Tools -> References
    Dim oAppt As AppointmentItem
    Dim Remind_Time As Double

    i = 2
    Subj = ThisWorkbook.Sheets(1).Cells(i, 1)

    'Loop through entire list of Reminders to be added
    While Subj <> ""
        Set oAppt = Outlook.Application.CreateItem(olAppointmentItem)

        oAppt.Subject = Subj
        oAppt.Location = ThisWorkbook.Sheets(1).Cells(i, 2)
        oAppt.Start = ThisWorkbook.Sheets(1).Cells(i, 3)
        Remind_Time = ThisWorkbook.Sheets(1).Cells(i, 4) * 1 * 60
        oAppt.ReminderMinutesBeforeStart = Remind_Time
        oAppt.AllDayEvent = True
        oAppt.Save

        i = i + 1
        Subj = ThisWorkbook.Sheets(1).Cells(i, 1)
    Wend
    MsgBox "Reminder(s) Added To Outlook Calendar"

End Sub

' The code comes from this link:

http://officetricks.com/add-appointment-to-outlook-calendar-through-excel-macro-vba/

我实际上写了一本关于这个以及其他很多东西的书。您可以在下面的链接中找到它。

https://www.amazon.com/Automating-Business-Processes-Reducing-Increasing-ebook/dp/B01DJJKVZC?ie=UTF8&keywords=ryan%20shuell&qid=1463837322&ref_=sr_1_1&sr=8-1