Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Handling of Double or Single Quotation Marks in ConversationTopic (http://www.outlookbanter.com/add-ins-outlook/70641-handling-double-single-quotation-marks.html)

RN April 20th 08 10:14 AM

Handling of Double or Single Quotation Marks in ConversationTopic
 
Hi,

I have an issue here in using the Restrict method to confine my result set
to a specific topic. In both cases below EmailSubject is a string passed in
to a method that handle the statement.

Case 1 (use of escaped double quotes in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]=\"" +
EmailSubject + "\"");
--- This will fail if there is any double quotation mark in the
ConversationTopic field.

Whereas

Case 2 (use of single quotation mark in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]='" +
EmailSubject + "'");
--- This will fail if there is any single quotation mark in the
ConversationTopic field.

Both Case 1 and Case 2 work fine if there is no single or double quotation
marks present in the ConversationTopic field.

So I got a problem in either case. Does anyone have any suggestion in
handling or bypassing the presence of either the double or the single
quotation marks in ConversationTopics?

Thanks.
Robin

Ken Slovak - [MVP - Outlook] April 21st 08 02:33 PM

Handling of Double or Single Quotation Marks in ConversationTopic
 
Test it both ways using an OR clause.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RN" wrote in message
...
Hi,

I have an issue here in using the Restrict method to confine my result set
to a specific topic. In both cases below EmailSubject is a string passed
in
to a method that handle the statement.

Case 1 (use of escaped double quotes in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]=\"" +
EmailSubject + "\"");
--- This will fail if there is any double quotation mark in the
ConversationTopic field.

Whereas

Case 2 (use of single quotation mark in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]='" +
EmailSubject + "'");
--- This will fail if there is any single quotation mark in the
ConversationTopic field.

Both Case 1 and Case 2 work fine if there is no single or double quotation
marks present in the ConversationTopic field.

So I got a problem in either case. Does anyone have any suggestion in
handling or bypassing the presence of either the double or the single
quotation marks in ConversationTopics?

Thanks.
Robin



PGS123 April 22nd 08 02:34 AM

Handling of Double or Single Quotation Marks in ConversationTo
 
Hi Ken,

I did. What I did was to detect the presence of single quote in
ConversationTopic then I will use double quotes in my Restrict criteria. And
if I detected the presence of double quote in ConversationTopic then I will
use single quotes in my Restrict criteria. This works out well. But the
problem is when both the single and double quotes are present in
ConversationTopic then I don't know how to write my Restrict criteria.

Regards,
Robin

"Ken Slovak - [MVP - Outlook]" wrote:

Test it both ways using an OR clause.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"RN" wrote in message
...
Hi,

I have an issue here in using the Restrict method to confine my result set
to a specific topic. In both cases below EmailSubject is a string passed
in
to a method that handle the statement.

Case 1 (use of escaped double quotes in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]=\"" +
EmailSubject + "\"");
--- This will fail if there is any double quotation mark in the
ConversationTopic field.

Whereas

Case 2 (use of single quotation mark in search string):
MyMailItems = SelectedFolder.Items.Restrict("[ConversationTopic]='" +
EmailSubject + "'");
--- This will fail if there is any single quotation mark in the
ConversationTopic field.

Both Case 1 and Case 2 work fine if there is no single or double quotation
marks present in the ConversationTopic field.

So I got a problem in either case. Does anyone have any suggestion in
handling or bypassing the presence of either the double or the single
quotation marks in ConversationTopics?

Thanks.
Robin




Ken Slovak - [MVP - Outlook] April 22nd 08 02:56 PM

Handling of Double or Single Quotation Marks in ConversationTo
 
Hmmm. Have you tried doubling up any single quotes to escape them when
they're in the EmailSubject string? Then you could try just using single
quotes surrounding the EmailSubject part of the restriction.

string test = EmailSubject;

// first clause has single quote within double quotes,
// second clause has 2 single quotes within double quotes.
EmailSubject = test.Replace("'", "''");

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"PGS123" wrote in message
...
Hi Ken,

I did. What I did was to detect the presence of single quote in
ConversationTopic then I will use double quotes in my Restrict criteria.
And
if I detected the presence of double quote in ConversationTopic then I
will
use single quotes in my Restrict criteria. This works out well. But the
problem is when both the single and double quotes are present in
ConversationTopic then I don't know how to write my Restrict criteria.

Regards,
Robin



PGS123 April 23rd 08 04:41 AM

Handling of Double or Single Quotation Marks in ConversationTo
 
No luck. I think the problem here is the property of ConversationTopic is
readonly. Even if it is a read/write property it will be a hassle to replace
each and everyone of the same ConversationTopic due to performance issues.
Another issue is that the Restrict method will hunt for all identical
ConversationTopic in Outlook folders and thus changing a particular instance
of the ConversationTopic will not help.

Robin


"Ken Slovak - [MVP - Outlook]" wrote:

Hmmm. Have you tried doubling up any single quotes to escape them when
they're in the EmailSubject string? Then you could try just using single
quotes surrounding the EmailSubject part of the restriction.

string test = EmailSubject;

// first clause has single quote within double quotes,
// second clause has 2 single quotes within double quotes.
EmailSubject = test.Replace("'", "''");

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"PGS123" wrote in message
...
Hi Ken,

I did. What I did was to detect the presence of single quote in
ConversationTopic then I will use double quotes in my Restrict criteria.
And
if I detected the presence of double quote in ConversationTopic then I
will
use single quotes in my Restrict criteria. This works out well. But the
problem is when both the single and double quotes are present in
ConversationTopic then I don't know how to write my Restrict criteria.

Regards,
Robin




Ken Slovak - [MVP - Outlook] April 23rd 08 02:27 PM

Handling of Double or Single Quotation Marks in ConversationTo
 
I wasn't suggesting trying to change the read-only ConversationTopic
property. I was suggesting trying massaging the EmailSubject variable that
way. Other than that I have no other suggestions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"PGS123" wrote in message
...
No luck. I think the problem here is the property of ConversationTopic is
readonly. Even if it is a read/write property it will be a hassle to
replace
each and everyone of the same ConversationTopic due to performance issues.
Another issue is that the Restrict method will hunt for all identical
ConversationTopic in Outlook folders and thus changing a particular
instance
of the ConversationTopic will not help.

Robin



PGS123 April 24th 08 01:40 AM

Handling of Double or Single Quotation Marks in ConversationTo
 
Hi Ken,

It's ok. Thanks for your help thus far.

Robin

"Ken Slovak - [MVP - Outlook]" wrote:

I wasn't suggesting trying to change the read-only ConversationTopic
property. I was suggesting trying massaging the EmailSubject variable that
way. Other than that I have no other suggestions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"PGS123" wrote in message
...
No luck. I think the problem here is the property of ConversationTopic is
readonly. Even if it is a read/write property it will be a hassle to
replace
each and everyone of the same ConversationTopic due to performance issues.
Another issue is that the Restrict method will hunt for all identical
ConversationTopic in Outlook folders and thus changing a particular
instance
of the ConversationTopic will not help.

Robin





All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com