Problem with FIND

  • Thread starter Herbert Gottlieb
  • Start date

H

Herbert Gottlieb

Hello,
i have problems with the use of find:

Dim iFItem As Integer
Dim OlApp As Outlook.Application, olMail As Outlook.MailItem
Dim strSenderName As String, strCreationTime As String, strReceivedTime As
String, strSubject as String

Set olApp = Outlook.Application
Set olMail = ActiveExplorer.Selection.Item(1)
strSenderName = olMail.SenderName
strCreationTime = olMail.CreationTime
strReceivedTime = olMail.ReceivedTime
strSubject= olMail.Subject

Gosub GetSubfolder 'Find Archivfolder 'Returns ->Nr: iFItem, or
Exit

With olApp.ActiveExplorer.CurrentFolder
Set olMail = .Folders.Item(iFItem).Items.Find("[SenderName] = "
& Chr(34) & _
strSenderName & Chr(34))
Debug.Print "40", olMail.SenderName, olMail.Subject,
olMail.CreationTime, olMail.ReceivedTime
End With
Set olApp=Nothing
Set olMail=Nothing

My problems:
If i use 1)
.....Find("[Subject] = " & chr(34) & strSubject & chr(34)):
a) it finds the first Subject, it doesn't matter if it is a forewarded mail
(WG: in german; FWD: in english version) or not
b) if the selected mail is an forwarded mail ( WG: or FWD: at the beginning
of the subject), so i get an error at the search;

2)searching by date and time: i was not able to search like
.....Find("[ReceivedTime] = " & chr(34) & strReceivedTime & chr(34)) it
doesn't work
also i've formated in different ways and canceld the seconds

Thanks for help
Herbert
 
Ad

Advertisements

D

Dmitry Streblechenko

1. When you specify Subject as the search criteria, Outlook searches for all
items with teh matching conversation index (subject minus a prefix). Use the
value of MailItem.ConversationTopic rather than MailItem.Subject
2. When searching for a date/time property, always use a range (+- 1 minute
would work). Exact match won't work due to the round-off errors.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Ad

Advertisements

H

Herbert Gottlieb

Thanks,

for the infos, I've solved it that way and didn't use Subject with find.

Herbert

Dmitry Streblechenko said:
1. When you specify Subject as the search criteria, Outlook searches for
all items with teh matching conversation index (subject minus a prefix).
Use the value of MailItem.ConversationTopic rather than MailItem.Subject
2. When searching for a date/time property, always use a range (+- 1
minute would work). Exact match won't work due to the round-off errors.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Herbert Gottlieb said:
Hello,
i have problems with the use of find:

Dim iFItem As Integer
Dim OlApp As Outlook.Application, olMail As Outlook.MailItem
Dim strSenderName As String, strCreationTime As String, strReceivedTime
As String, strSubject as String

Set olApp = Outlook.Application
Set olMail = ActiveExplorer.Selection.Item(1)
strSenderName = olMail.SenderName
strCreationTime = olMail.CreationTime
strReceivedTime = olMail.ReceivedTime
strSubject= olMail.Subject

Gosub GetSubfolder 'Find Archivfolder 'Returns ->Nr: iFItem, or
Exit

With olApp.ActiveExplorer.CurrentFolder
Set olMail = .Folders.Item(iFItem).Items.Find("[SenderName] =
" & Chr(34) & _
strSenderName & Chr(34))
Debug.Print "40", olMail.SenderName, olMail.Subject,
olMail.CreationTime, olMail.ReceivedTime
End With
Set olApp=Nothing
Set olMail=Nothing

My problems:
If i use 1)
....Find("[Subject] = " & chr(34) & strSubject & chr(34)):
a) it finds the first Subject, it doesn't matter if it is a forewarded
mail (WG: in german; FWD: in english version) or not
b) if the selected mail is an forwarded mail ( WG: or FWD: at the
beginning of the subject), so i get an error at the search;

2)searching by date and time: i was not able to search like
....Find("[ReceivedTime] = " & chr(34) & strReceivedTime & chr(34)) it
doesn't work
also i've formated in different ways and canceld the seconds

Thanks for help
Herbert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top