?
Solved

Outlook & VB Problem

Posted on 2003-03-12
7
Medium Priority
?
202 Views
Last Modified: 2010-04-07
I'm trying put in only one e-mail, the one with the matching subject and body. To do this i'm passing the function the subject and body and they are called pSubject and pBody.


    'Set mr = Inbox.Items.Restrict("[Subject] = '" & pSubject & "' AND [Body] = '" & pBody & "'")
   
    Set mr = Inbox.Items.Restrict("[Subject] = '" & pSubject & "'")

The commentted out line is the one i really ant to use but the second one is for testing and this one doesn't work.

It works IF the subject passed in pSubject contains no single quotes '
As soon as a single quote appears it dies.

What i'm looing for is, is there some way of escaping the ' here '" & pSubject & "'. I know in perl i would just simplely \' and it would work but i can't figure out a way of doing it here.

Cheers
0
Comment
Question by:g_land
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:g_land
ID: 8128940
anyone have any possible answers, i'd really stuck on this and can;t move on till i get this.

Cheers
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 8139124
Set mr = Inbox.Items.Restrict("[Subject] = '" & replace(pSubject,"'",vbnullstring) & "'")
If you are using VB6 the replace function will replace all occurances of the single quote with nothing.
0
 

Author Comment

by:g_land
ID: 8142326
i tried that but because it replaces the 1 with nothing it fails the search to find the subject!

Thanks for the suggestion
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Accepted Solution

by:
g_land earned 0 total points
ID: 8142942
for future reference the answer is:

Set mr = Inbox.Items.Restrict("[Subject] = """ & pSubject & """")

George
0
 

Expert Comment

by:CleanupPing
ID: 9056388
g_land:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9664565
g_land, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question