0

我无法创建会议请求。我在 .HTMLbody 行出现错误。我收到的错误是“运行时错误'438'对象不支持此属性或方法”。我还添加了 Ron De'Bruin 的 RangeToHTML 代码。

请协助我提出请求。

这是我的代码:

Sub Meeting_Request()
Dim myoutlook As Object ' Outlook.Application
Dim r As Long
Dim rng As Range
Dim rng2 As Range
Dim myapt As Object ' Outlook.AppointmentItem

' late bound constants
Const olAppointmentItem = 1
Const olBusy = 2
Const olMeeting = 1

' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")

' Start at row 18
Sheets("Automation").Select
r = 18

Do Until Trim$(Cells(r, 1).Value) = ""
'Adding Goals and other details in email draft


Set rng = Nothing
On Error Resume Next
Set rng = Range("A9:A14").SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If rng Is Nothing Then
    MsgBox "The selection is not a range or the sheet is protected" & _
           vbNewLine & "please correct and try again.", vbOKOnly
    Exit Sub
End If

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




'Sheets("Automation").Select
' Create the AppointmentItem

Set myapt = myoutlook.CreateItem(olAppointmentItem)
' Set the appointment properties
'Sheets("Automation").Select
With myapt
  .Subject = Sheets("Automation").Range("N" & r) & " day review"
  .Start = Sheets("Automation").Range("P" & r) & " " & "7:00:00 PM"
  .Duration = 0
  .Recipients.Add Sheets("Automation").Range("C" & r).Value & ";" & Sheets("Automation").Range("K" & r).Value
  .MeetingStatus = olMeeting
  ' not necessary if recipients are email addresses
  ' myapt.Recipients.ResolveAll
  '.AllDayEvent = "No"
    .BusyStatus = olBusy
   ' .BusyStatus = Cells(r, 5).Value
    .ReminderSet = False
  .HTMLBody = RangetoHTML(rng)
  .Save
  r = r + 1
  .Display
End With

Loop
End Sub
4

1 回答 1

1

约会项目对正文使用 RTF 标记而不是 HTML(请参阅RTFBody属性)。因此,您将找不到HTMLBody用于约会的物业。如果需要将一些 HTML 标记粘贴到正文,可以使用 Word 对象模型。有关详细信息,请参阅使用 C# 将 HTML 内容写入 Word 文档

从 Outlook 2016 开始,您可以尝试PR_HTML使用 AppointmentItem.PropertyAccessor 访问代表 HTML 正文的属性。DASL 名称是http://schemas.microsoft.com/mapi/proptag/0x10130102

于 2018-06-17T04:26:10.550 回答