|
Sri Potluri
Posts: 14
Joined: 2016-05-13
|
Hi,
I am working on a project which requires me to filter the emails in a certain store based on a certain filter criteria and display the filtered result in the Explorer window. I am curious if this is possible and if I can display the output filtered list in the explorer window so the user can click on any email he wants to view.
Please let me know.
Thanks,
Sri |
|
Posted 09 Sep, 2016 09:45:12
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Sri,
If you need to filter emails in a certain folder of a certain Outlook store, the answer is almost yes. "Almost" this is because some message store types may be implemented in a way that doesn't do (implement) something that your code might use.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 09 Sep, 2016 10:01:38
|
|
Top
|
|
Sri Potluri
Posts: 14
Joined: 2016-05-13
|
Thanks Andrei. Is it possible to programatically display that filtered list in the Explorer window? |
|
Posted 09 Sep, 2016 10:37:03
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
|
Posted 12 Sep, 2016 03:33:34
|
|
Top
|
|
Sri Potluri
Posts: 14
Joined: 2016-05-13
|
Thanks Andrei. I am using View and Filter to get a list of emails with the address I input either present in from, to, cc or bcc. I am able to get the fromemail working in the httpmail namespace but I am trying to get the cc/to/bcc working and I cannot.
I tried both httpmail and mailheader namespaces but I am not sure what is wrong. I am pasting my code below. Please have a look at it.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles bFilter.Click
Dim sFilter As String
Dim CurrentExplorer As Outlook.Explorer = Nothing
Dim CurrentView As Outlook.View = Nothing
Dim CurrentXML As XmlDocument = New XmlDocument
Dim CurrentFilterNodes, CurrentViewNodes As XmlNodeList
Dim CurrentFilterNode, CurrentParentNode As XmlNode
If TextBox1.Text.Length > 0 Then
sFilter = "urn:schemas:httpmail:to LIKE '%" + TextBox1.Text.Trim + "%'"
CurrentExplorer = TryCast(ExplorerObj, Outlook.Explorer)
If (CurrentExplorer IsNot Nothing) Then
CurrentView = CurrentExplorer.CurrentView
If (CurrentView IsNot Nothing) Then
Try
CurrentXML.LoadXml(CurrentView.XML)
CurrentFilterNodes = _
CurrentXML.GetElementsByTagName("filter")
If CurrentFilterNodes.Count > 0 Then
For y As Integer = 0 _
To CurrentFilterNodes.Count - 1
CurrentFilterNode = CurrentFilterNodes(y)
If CurrentFilterNode.HasChildNodes Then
For i As Integer = _
CurrentFilterNode.ChildNodes.Count - 1 _
To 0 Step -1
CurrentFilterNode.RemoveChild( _
CurrentFilterNode.ChildNodes(i))
Next
End If
Next
CurrentFilterNode = CurrentFilterNodes(0)
CurrentFilterNode.AppendChild( _
CurrentXML.CreateTextNode(sFilter))
Else
CurrentViewNodes = CurrentXML. _
GetElementsByTagName("view")
If CurrentViewNodes IsNot Nothing Then
CurrentParentNode = CurrentViewNodes(0)
CurrentFilterNode = CurrentXML. _
CreateElement("filter")
CurrentParentNode.AppendChild( _
CurrentFilterNode)
CurrentFilterNode.AppendChild( _
CurrentXML.CreateTextNode(sFilter))
End If
End If
CurrentView.XML = CurrentXML.InnerXml
CurrentView.Apply()
Finally
Marshal.ReleaseComObject(CurrentView)
End Try
End If
End If
End If |
|
Posted 12 Sep, 2016 16:38:19
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
|
Posted 13 Sep, 2016 09:08:42
|
|
Top
|
|
Sri Potluri
Posts: 14
Joined: 2016-05-13
|
Andrei, I am trying to achieve this via program and not through the Outlook application. On a button click in the ADXOl form, I need the filtered emails to show up. I can get the fromemail filter working through the program but not sure why the to/cc/bcc don't. |
|
Posted 13 Sep, 2016 09:44:29
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Ah, that's my fault. I should have said that the SQL tab allows you to copy the correct filter string!
Here's an example filter I created a moment ago: "urn:schemas:httpmail:displaycc" LIKE '%qqq%
Hope this helps.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 13 Sep, 2016 09:51:05
|
|
Top
|
|
Sri Potluri
Posts: 14
Joined: 2016-05-13
|
|
Posted 13 Sep, 2016 09:59:58
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
You are welcome!
Andrei Smolin
Add-in Express Team Leader |
|
Posted 14 Sep, 2016 05:07:25
|
|
Top
|
|