我正在开发一个代码来提取团队为会议提议的新时间。
但是在“If objMeeting.MeetingResponseStatus = olResponseAccepted Then”这一行中说“Object doesn't support this property or method”。我看到了ObjMeeting的所有属性,这是如此有限:
(申请
班级
会议
家长
行动
附件
计费信息
身体
分类目录
企业
会话索引
会话主题
创建时间
入口ID
表单描述
GetInspector
重要性
最后修改时间
消息类
里程
无老化
OutlookInternalVersion
OutlookVersion
得救了
灵敏度
尺寸
主题
未读
用户属性
自动转发
延迟交货时间
提交后删除
失效时间
发起人交付报告请求
接收时间
接受者
提醒设置
提醒时间
回复收件人
SaveSentMessageFolder
发送者名称
发送
SentOn
已提交
下载状态
项目属性
MarkForDownload
冲突
MeetingWorkspaceURL AutoResolvedWinner
冲突
发件人电子邮件地址
发件人电子邮件类型
属性访问器
对话ID
发送使用帐户
是最新版本
RTF正文
保留到期日期
保留策略名称
BodyFormat
调度服务会议选项URL
Skype团队会议ETag
Skype团队会议URL
SkypeTeamsProperties
团队VtcConferenceId
TeamsVtcTenantId)
我找不到时间的建议。
代码:
Function SheetExists(sheetName As String, Optional wb As Workbook) As Boolean
Dim s As Worksheet
On Error Resume Next
If wb Is Nothing Then Set wb = ThisWorkbook
Set s = wb.Sheets(sheetName)
SheetExists = Not s Is Nothing
End Function
Sub SaveNewTimeProposedToExcel()
Dim objNamespace As Outlook.Namespace
Dim objFolder As Outlook.Folder
Dim objMail As Outlook.MailItem
Dim strNewTimeProposed As Date
Dim objWorkbook As Excel.Workbook
Dim objMeeting As Outlook.MeetingItem
Dim objItem As Object
Dim lngRow As Long
Set Base = ActiveWorkbook
'Define o namespace e a pasta da caixa de entrada
Set objNamespace = Outlook.Application.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
'Abre o arquivo existente
Set objWorkbook = Workbooks.Open("C:\Users\genascim\Desktop\Gregory Project\Gregory_database.xlsx")
'Verifica se a planilha "New Time Proposed" já existe e cria uma nova planilha com um nome diferente, se necessário
Dim strSheetName As String
Dim intSheetCount As Integer
intSheetCount = 1
strSheetName = "New Time Proposed"
Do While SheetExists(strSheetName, objWorkbook)
intSheetCount = intSheetCount + 1
strSheetName = "New Time Proposed " & intSheetCount
Loop
'Adiciona a nova planilha e define a primeira linha como cabeçalho
Set objWorksheet = objWorkbook.Sheets.Add(After:=objWorkbook.Sheets(objWorkbook.Sheets.Count))
objWorksheet.Name = strSheetName
objWorksheet.Cells(1, 1).Value = "Remetente"
objWorksheet.Cells(1, 2).Value = "Nova hora proposta"
Set objMailItems = objFolder.Items.Restrict("[ReceivedTime] > '" & Format(Date - 7, "ddddd h:nn AMPM") & "'")
'Loop através dos itens da pasta da caixa de entrada
For Each objItem In objMailItems
If TypeOf objItem Is Outlook.MailItem Then
Set objMail = objItem
Debug.Print "Processing email: " & objMail.Subject
ElseIf TypeOf objItem Is Outlook.MeetingItem Then
Set objMeeting = objItem
'Check if the email item is a meeting request
If objMeeting.MeetingResponseStatus = olResponseAccepted Then
'Check if the response contains a new time proposal
If objMeeting.MeetingStatus = olMeetingReceivedAndCanceled Or objMeeting.MeetingStatus = olMeetingReceivedAndDeclined Or objMeeting.MeetingStatus = olMeetingReceived Then
If InStr(1, objMeeting.Body, "new time proposed", vbTextCompare) > 0 Then
'Extract the new time proposed
strNewTimeProposed = objMeeting.GetAssociatedAppointment(True).Start
'Add the sender and new time proposed to the worksheet
lngRow = objWorksheet.Cells(objWorksheet.Rows.Count, 1).End(xlUp).Row + 1
objWorksheet.Cells(lngRow, 1).Value = objMail.SenderName
objWorksheet.Cells(lngRow, 2).Value = strNewTimeProposed
End If
End If
End If
End If
Next objItem
'Salva o livro
objWorkbook.Save
End Sub
我已经尝试了属性.Start或.StarUTC,但两者都不起作用。
2条答案
按热度按时间owfi6suc1#
MeetingResponseStatus
是Recipient对象的属性,而不是AppointmentItem
或MeetingItem
。如果您有一个
MeetingItem
对象,请使用MeetingItem.GetAssociatedAppointment
检索相应的AppointmentItem
对象,然后使用AppointmentItem.ResponseStatus
属性。35g0bw712#
我做了一些修改,现在它正在工作,但显示的日期/时间是原来的,而不是发件人提出的。
Sub SaveNewTimeProposedToExcel()Dim objNamespace As Outlook.Namespace Dim objFolder As Outlook.Folder Dim objMail As Outlook.MailItem Dim strNewTimeProposed As Date Dim objWorkbook As Excel.Workbook Dim objMeeting As Outlook.MeetingItem Dim objItem As Object