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

  • Thread starter Thread starter Shelby
  • Start date Start date
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
 
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.
 
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
 
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]
=
 
Back
Top