获取OutLook邮件主题和接收时间

Sub Getoutlook()
Dim ol As Object, dates As Date, t%, i%
i = sheet5.Range("b65536").End(xlUp).Row
Set ol = CreateObject("outlook.application") '后期绑定
For Each r In ol.getnamespace("MAPI").getdefaultfolder(6).Folders("APPLY").items '遍历收件箱中子文件夹为"APPLY"中的邮件
If r.unread Then '如果邮件状态为未读
dates = Format(r.creationtime, "yyyy/m/d") '对接收时间格式化
If InStr(r.Subject, "答复") = False Then '对主题设置过滤条件
r.unread = False
t = t + 1
sheet5.Cells(i + t, "b") = r.Subject '获取主题
sheet5.Cells(i + t, "g") = r.creationtime '获取接收时间
End If
End If
End If
Next
If t = 0 Then
MsgBox "无符合条件的数据"
Else
MsgBox "提取完毕"
End If
Set ol = Nothing
End Sub

posted @ 2019-10-26 23:44  zhujie-  阅读(1714)  评论(0编辑  收藏  举报