Problem with the Contacts

G

G.V.Reddy

Hi,

I'm new to VBA and Outlook. My requirement is as follows:

I would like to monitor the each email ID before sending out any email, so
the emails should not be sent to other than our domain say "@xyz.com". I've
written a script in which I could access the To, CC, and BCC fields with the
Item object. I could split the email IDs using ";" as delimiter and checked
each email ID whether it is ending with "@xyz.com" or not. But as some email
IDs are entered from Contacts, the Item object displays the "Email Name"
rather email ID for that contact. Can anybody please help me how to find out
the email ID associated with the Contact displayed in the To, CC or BCC
fields?

Thanks in advance.

Venkat
 
M

Michael Bauer

Am Tue, 6 Sep 2005 15:31:31 +0530 schrieb G.V.Reddy:

Venkat, you´re talking about e-mail addresses, not IDs. Please have a look
at the Recipients collection. Each Recipient object has an Address property.
 
G

G.V.Reddy

Dear Michael,

Thanks a lot for your help. Can you please provide me sample code to parse
through the Recipients collection.

Best regards,
Venkat
 
M

Michael Bauer

Am Tue, 6 Sep 2005 16:27:05 +0530 schrieb G.V.Reddy:

Dim sAdr as string
Dim lAdr as Long
Dim oRecip as Outlook.Recipient
sAdr=LCase$("@yourDomain.com")
lAdr=Len(sAdr)
For Each oRecip in YourMailItem.Recipients
If LCase$(Right$(oRecip.Address,lAdr))<>sAdr Then
' do something with the wrong address
Endif
Next
 
G

G.V.Reddy

Dear Michael,

Thanks a lot for the sample code.

Best regards,
Venkat Reddy Gaddam
 

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