Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / April 2008

Tip: Looking for answers? Try searching our database.

Handling of Double or Single Quotation Marks in ConversationTopic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RN - 20 Apr 2008 10:14 GMT
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] - 21 Apr 2008 14:33 GMT
Test it both ways using an OR clause.

Signature

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

> Hi,
>
[quoted text clipped - 26 lines]
> Thanks.
> Robin
PGS123 - 22 Apr 2008 02:34 GMT
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

> Test it both ways using an OR clause.
>
[quoted text clipped - 28 lines]
> > Thanks.
> > Robin
Ken Slovak - [MVP - Outlook] - 22 Apr 2008 14:56 GMT
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("'", "''");

Signature

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

> Hi Ken,
>
[quoted text clipped - 9 lines]
> Regards,
> Robin
PGS123 - 23 Apr 2008 04:41 GMT
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

> 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
[quoted text clipped - 19 lines]
> > Regards,
> > Robin
Ken Slovak - [MVP - Outlook] - 23 Apr 2008 14:27 GMT
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.

Signature

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

> 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
[quoted text clipped - 6 lines]
>
> Robin
PGS123 - 24 Apr 2008 01:40 GMT
Hi Ken,

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

Robin

> I wasn't suggesting trying to change the read-only ConversationTopic
> property. I was suggesting trying massaging the EmailSubject variable that
[quoted text clipped - 10 lines]
> >
> > Robin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.