Outlook search from Access

  • Thread starter Thread starter llamadave
  • Start date Start date
L

llamadave

Sending email from Access is working great for me. Now I want to click on an
email address in an Access 2007 form, then go automatically to Outlook with
the search box filled in with the email address and search "All Mail Items".

David
 
Its not possible to put the email address in the search box, however it is
entirely do a search using code. The Outlook group will guide you in your
quest grasshopper.
 
You can do it, but it took me a while to figure it out. This works great:

Private Sub Command540_Click()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim EmailTxt As String
EmailTxt = Me!Email1 & " OR " & Me!Email2
Set myOlExp = myOlApp.ActiveExplorer
myOlExp.Search EmailTxt, 1
myOlExp.Display
End Sub
 
llamadave said:
You can do it, but it took me a while to figure it out. This works great:

Private Sub Command540_Click()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim EmailTxt As String
EmailTxt = Me!Email1 & " OR " & Me!Email2
Set myOlExp = myOlApp.ActiveExplorer
myOlExp.Search EmailTxt, 1
myOlExp.Display
End Sub

You would be well advised to include:

Set myOlExp = Nothing
Set myOlApp = Nothing

just before the End Sub

VBA is supposed to do this automatically when they go out of scope, but it's
not always reliable.
 
Back
Top