Dear All,
I have a routine where I have to search emails in Outlook with a specific subject.
It goes like this:
As you can see, I use Outlook AdvancedSearch method and there's a lot of waiting in it because of the AdvancedSearch method's asynchronous working. (15 seconds to be exact.) I've found this solution in another form. Now it's sometimes unnecessarily lot, sometimes not enough.
I found out that AdvancedSearch has an AdvancedSearchComplete event that can be used to detect when the search actually finished, but I found only a Visual Basic example of it and I don't know how to implement it in Visual FoxPro. It should be
but I don't know how to "translate" it to Visual FoxPro and where to insert it in my code.
Any help would be appreciated.
I have a routine where I have to search emails in Outlook with a specific subject.
It goes like this:
Code:
loOutlook=CREATEOBJECT("Outlook.Application")
loSearch=loOutlook.AdvancedSearch("'Inbox'","urn:schemas:mailheader:subject like '%"+ALLTRIM(STR(this.gsz))+"%'",.t.,ALLTRIM(STR(this.gsz)))
WAIT '' TIMEOUT 5
IF loSearch.results.count=0
WAIT '' TIMEOUT 5
IF loSearch.results.count=0
WAIT '' TIMEOUT 5
IF loSearch.results.count=0
=MESSAGEBOX("No match.",48,ALLTRIM(STR(this.gsz))+" email search")
RELEASE loOutlook,loSearch
RETURN .f.
ENDIF
ENDIF
ENDIF
this.grid1.RecordSource=''
CREATE CURSOR emailsrch (sendername C(80),subject C(80),received T,esize i(8),mailto C(80),mailcc C(80),body M,htmlbody M)
INDEX ON received TAG received
FOR EACH loItem IN loSearch.Results
INSERT INTO emailsrch VALUES (loItem.sendername,loItem.subject,loItem.receivedtime,loItem.size,loItem.to,loItem.cc,loItem.body,loItem.htmlbody)
ENDFOR
...etc.
As you can see, I use Outlook AdvancedSearch method and there's a lot of waiting in it because of the AdvancedSearch method's asynchronous working. (15 seconds to be exact.) I've found this solution in another form. Now it's sometimes unnecessarily lot, sometimes not enough.
I found out that AdvancedSearch has an AdvancedSearchComplete event that can be used to detect when the search actually finished, but I found only a Visual Basic example of it and I don't know how to implement it in Visual FoxPro. It should be
Code:
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
MsgBox "The AdvancedSearchComplete Event fired."
blnSearchComp = True
End Sub
but I don't know how to "translate" it to Visual FoxPro and where to insert it in my code.
Any help would be appreciated.