Hunter的大杂烩 技术学习笔记

2014-05-07

统计最近一个月outlook发件人vba

Filed under: 技术话题 — hunter @ 12:35 pm

Function getDateInt(dateStr) As Long

getDateInt = 0
pos1 = InStr(dateStr, “/”)
If pos1 > 0 Then
pos2 = InStr(pos1 + 1, dateStr, “/”)
If pos2 > 0 Then

yearInt = Left(dateStr, pos1 – 1)
monthInt = Mid(dateStr, pos1 + 1, pos2 – pos1 – 1)
dayInt = Right(dateStr, Len(dateStr) – pos2)
getDateInt = yearInt * 10000 + monthInt * 100 + dayInt

End If
End If
End Function

Sub MTest()
Dim BodyFile As String
Dim olMailItem As MailItem
Dim rMailItem As MailItem
Dim myComments As String
Dim myOlSel As Outlook.Selection

Dim subj As String
myComments = “___OK____: ”

Set myOlSel = Application.ActiveExplorer.Selection
For i = 1 To myOlSel.Count
Set olMailItem = myOlSel.Item(i)
Debug.Print olMailItem.CreationTime & “|” & olMailItem.SenderName & “|” & olMailItem.Subject
createDateTimeStr = olMailItem.CreationTime
pos = InStr(createDateTimeStr, ” “)
If pos > 0 Then
createDateStr = Left(createDateTimeStr, pos)
dateInt1 = getDateInt(createDateStr)
dateInt2 = getDateInt(“2014/4/7”)
If dateInt1 = 0 Then
Exit For
End If
If dateInt1 < dateInt2 Then Exit For End If 'If StrComp(createDateStr, "2014/4/7") < 0 Then ' Exit For 'End If End If Next Set rMailItem = Nothing Set olMailItem = Nothing End Sub

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress