PDA

View Full Version : CC count with certain e-mail adrress problem



saban
02-14-2008, 12:10 PM
Dim olTask As Outlook.TaskItem
'Using object rather than MailItem, so that it
'can handle posts, meeting requests, etc as well
Dim olItem As MailItem
Dim olExp As Outlook.Explorer
Dim fldCurrent As Selection
Dim olApp As Outlook.Application

Set olApp = Outlook.CreateObject("Outlook.Application")
Set olTask = olApp.CreateItem(olTaskItem)
Set olExp = olApp.ActiveExplorer
Set fldCurrent = ActiveExplorer.Selection

Dim cntSelection As Integer
cntSelection = olExp.Selection.count
If cntSelection = 0 Then
MsgBox "please select mails"
Exit Sub
End If
For Each olItem In fldCurrent
If olItem.CC = "57filter@gmail.com" Then
i5 = i5 + 1
End If
Next

MsgBox "there are:" & vbCrLf & i5 & " CC Mails"
End Sub


I ran into problem:
When mails with 57filter@gmail.com in CC field are counted the ones which have 57filter@gmail.com in second third etc. place are not counted

It just counts the ones which have 57filter@gmail.com on first place

Weird does anyone knows why is that

Trevor
02-18-2008, 04:44 PM
Try changing:
For Each olItem In fldCurrent
If olItem.CC = "57filter@gmail.com" Then
i5 = i5 + 1
End If

To:
intCount = olItem.cc.Count
If intCount > 0 Then
For I = 1 To intCount
Next

MsgBox "there are:" & vbCrLf & i5 & " CC Mails"
End If
End Sub