Find method raise error because Email Address contain ('). How to solve that?

S

Shelby

Hi,
I'm trying to use the Find method to find a certain Email Address in Contact
Folder.


Dim val as string = " John'(e-mail address removed) "
Dim MyItem as outlook.ContactItem = MyFold.Items.Find("[Email1Address] = ' "
& val & " ' ")

It will have problem finding because of the (') in the email address.
How should I solve that?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Are you sure the problem is the search string and not the fact that reading
any of a contact's email addresses is restricted in secure versions of
Outlook? If you are using Outlook 2000 SP2 or later all the email addresses
are restricted for reading since that's one way that viruses and worms can
harvest email addresses they can use.
 
S

Shelby

Hi,

yes I'm aware of the security feature and I'm sure it's not that problem.

I'm sure it's this problem:
MyItem = MyFold.Items.Find( " [Email1Address] = ' John 'DCal @ email.com '
")
It is the apostrophere in the string.



Ken Slovak - said:
Are you sure the problem is the search string and not the fact that reading
any of a contact's email addresses is restricted in secure versions of
Outlook? If you are using Outlook 2000 SP2 or later all the email addresses
are restricted for reading since that's one way that viruses and worms can
harvest email addresses they can use.




Shelby said:
Hi,
I'm trying to use the Find method to find a certain Email Address in Contact
Folder.


Dim val as string = " John'(e-mail address removed) "
Dim MyItem as outlook.ContactItem = MyFold.Items.Find("[Email1Address] =
'
"
& val & " ' ")

It will have problem finding because of the (') in the email address.
How should I solve that?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Then in that case don't use single quotes to delimit the email address. Use
double quotes. Since it's sometimes hard to see how many double quotes to
add in a row to make things OK use Chr(34) for that to delimit the email
address.




Shelby said:
Hi,

yes I'm aware of the security feature and I'm sure it's not that problem.

I'm sure it's this problem:
MyItem = MyFold.Items.Find( " [Email1Address] = ' John 'DCal @ email.com '
")
It is the apostrophere in the string.



Ken Slovak - said:
Are you sure the problem is the search string and not the fact that reading
any of a contact's email addresses is restricted in secure versions of
Outlook? If you are using Outlook 2000 SP2 or later all the email addresses
are restricted for reading since that's one way that viruses and worms can
harvest email addresses they can use.




Shelby said:
Hi,
I'm trying to use the Find method to find a certain Email Address in Contact
Folder.


Dim val as string = " John'(e-mail address removed) "
Dim MyItem as outlook.ContactItem = MyFold.Items.Find("[Email1Address]
=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top