K
Ken Slovak - [MVP - Outlook]
Try something like this:
' previous existing code
Dim strSubject As String
Set objItem = Outlook.ActiveExplorer.Selection(1)
strSubject = Replace(objItem.Subject, " '", "''")
' other existing code
' this is all on one line
strSQL = "SELECT ""urn:schemas:httpmail:subject"" FROM Folder WHERE
(""urn:schemas:httpmail:subject"" = '" & strSubject & " ')"
Here is some code for testing:
Sub MapiTableSQLTest()
Dim objItem As Outlook.MailItem
Dim Table As Redemption.MAPITable
Dim Recordset
Dim strSQL As String
Set objItem = Outlook.ActiveExplorer.Selection(1)
Set Table = CreateObject("Redemption.MAPITable")
'Set Table = CreateObject("SafeOutlook.SecureMAPITable")
Table.Item = Outlook.ActiveExplorer.CurrentFolder.Items
strSQL = "SELECT ""urn:schemas:httpmail:subject"" FROM Folder
WHERE (""urn:schemas:httpmail:subject""='" & Replace(objItem.Subject,
"'", "''") & "')"
Set Recordset = Table.ExecSQL(strSQL)
While Not Recordset.EOF
Debug.Print Recordset.Fields(0).Value
Recordset.MoveNext
Wend
End Sub
If an email is marked with a prefix no records will be returnd.
Emails without prefix will be returned.
Peter
' previous existing code
Dim strSubject As String
Set objItem = Outlook.ActiveExplorer.Selection(1)
strSubject = Replace(objItem.Subject, " '", "''")
' other existing code
' this is all on one line
strSQL = "SELECT ""urn:schemas:httpmail:subject"" FROM Folder WHERE
(""urn:schemas:httpmail:subject"" = '" & strSubject & " ')"
Here is some code for testing:
Sub MapiTableSQLTest()
Dim objItem As Outlook.MailItem
Dim Table As Redemption.MAPITable
Dim Recordset
Dim strSQL As String
Set objItem = Outlook.ActiveExplorer.Selection(1)
Set Table = CreateObject("Redemption.MAPITable")
'Set Table = CreateObject("SafeOutlook.SecureMAPITable")
Table.Item = Outlook.ActiveExplorer.CurrentFolder.Items
strSQL = "SELECT ""urn:schemas:httpmail:subject"" FROM Folder
WHERE (""urn:schemas:httpmail:subject""='" & Replace(objItem.Subject,
"'", "''") & "')"
Set Recordset = Table.ExecSQL(strSQL)
While Not Recordset.EOF
Debug.Print Recordset.Fields(0).Value
Recordset.MoveNext
Wend
End Sub
If an email is marked with a prefix no records will be returnd.
Emails without prefix will be returned.
Peter