Hello,
Using Office 2010.
In access I have a form containing contact information of clients.
A button next to the e-mail of the client OPENS OUTLOOK and applies a filter to display only the e-mails from that client in OUTLOOK.
The filtermail function is as follows:
The code works fine, but only applies the filter to the folder currently open in OUTLOOK.
If you have multiple accounts you would have to first open the inbox or sent folder and then apply the filter. Rather cumbersome.
I would like to replace the code above to one where I can control the searchbar in outlook.
So selecting "All Mail Items" or "All Outlook Items", ranking the result by account or date and using the following queries "system.structuredquery.virtual.from: (name)" and "to: (name)".
Using the searchbar manually gives me the result I want. I can see all the history with a client across different accounts and folders. But having it automated would be great.
Is it possible and how can I achieve this.
In summation: when button clicked next to e-mail, open outlook and show messages from and to that e-mail.
Thanks
Using Office 2010.
In access I have a form containing contact information of clients.
A button next to the e-mail of the client OPENS OUTLOOK and applies a filter to display only the e-mails from that client in OUTLOOK.
Code:
Private Sub filterOutlook_Click()
'bit of code here which checks if outlook is open, if not then"
Shell "Outlook.exe /cleanviews"
'email of contact field(hyperlink) is retreived
contactname = Left$([E-mail contact].Value, InStr([E-mail contact].Value, "#") - 1)
filtermail contactname
End Sub
Code:
Public Sub filtermail(name As String)
Dim objView As View
Set objView = outlook.ActiveExplorer.CurrentView
If LenB(name) = 0 Then
objView.Filter = vbNullString
Else
objView.Filter = _
"http://schemas.microsoft.com/mapi/proptag/0x0065001f CI_STARTSWITH '" & name & "'"
End If
objView.Save
objView.Apply
End Sub
If you have multiple accounts you would have to first open the inbox or sent folder and then apply the filter. Rather cumbersome.
I would like to replace the code above to one where I can control the searchbar in outlook.
So selecting "All Mail Items" or "All Outlook Items", ranking the result by account or date and using the following queries "system.structuredquery.virtual.from: (name)" and "to: (name)".
Using the searchbar manually gives me the result I want. I can see all the history with a client across different accounts and folders. But having it automated would be great.
Is it possible and how can I achieve this.
In summation: when button clicked next to e-mail, open outlook and show messages from and to that e-mail.
Thanks