A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to extract email addresses from TO or CC line of a particular email



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 8th 09, 10:27 AM posted to microsoft.public.outlook.program_vba
Ivan[_2_]
external usenet poster
 
Posts: 2
Default How to extract email addresses from TO or CC line of a particular email

Hello

I'm using Outlook 2007 on Exchange and I'm having an email with a huge
amount of recipiens in the To and Co lines and I woul like to collect these
addresses into one of the subfolder of my Contacts folder.

OK, I can copy one email address at a time if I select only one address,
then pick out the "Add to Outlook Contacts" command from the mouse right
click menu. Evidently is this procedure more than retardatory.

If I select two or more addresses from any of both lines, then there isn't
any such "Add to Outlook Contacts" command on the content menu and I can
only copy the selected addresses to clipboard. As I can see nad understand
only the display name parts of the addresses are copied to cipboard and
these data are without real address not useful for me.

I'm sure that it should be some way to do this with VBA code. Could anybody
help me with a piece of code or a hint?

Ivan



Ads
  #2  
Old April 8th 09, 03:10 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to extract email addresses from TO or CC line of a particular email

Get the Recipients collection of the mail item and iterate that collection.
You can harvest whatever information you want from each Recipient (whatever
is available on that object).

When adding contacts using code you will not get any warning dialogs if you
try to add a duplicate contact. So any code must search in the Contacts to
see if such a contact already exists. How you determine a duplicate is up to
you. Names can be slightly different (Richard, Rich, Ricky) and so on, so
you have to account for that.

It's somewhat more complicated than it sounds like it would be.

--
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


"Ivan" wrote in message
...
Hello

I'm using Outlook 2007 on Exchange and I'm having an email with a huge
amount of recipiens in the To and Co lines and I woul like to collect
these addresses into one of the subfolder of my Contacts folder.

OK, I can copy one email address at a time if I select only one address,
then pick out the "Add to Outlook Contacts" command from the mouse right
click menu. Evidently is this procedure more than retardatory.

If I select two or more addresses from any of both lines, then there
isn't any such "Add to Outlook Contacts" command on the content menu and I
can only copy the selected addresses to clipboard. As I can see nad
understand only the display name parts of the addresses are copied to
cipboard and these data are without real address not useful for me.

I'm sure that it should be some way to do this with VBA code. Could
anybody help me with a piece of code or a hint?

Ivan




  #3  
Old April 9th 09, 12:09 PM posted to microsoft.public.outlook.program_vba
Ivan[_2_]
external usenet poster
 
Posts: 2
Default How to extract email addresses from TO or CC line of a particular email

Thank you Ken,

I play with some VBA code and below is a program for extracting the display
names and the addresses from all the emails od the specific outlook folder.
The results are in the Immediate window of MVB and an user can easily change
that part of the code:

Sub ExtractRecipientsFromEmail()
Dim OlApp As Outlook.Application
Dim MailObject As Object
Dim RecipientObject As Object
Dim Email As String
Dim NS As NameSpace
Dim Folder As MAPIFolder
Set OlApp = CreateObject("Outlook.Application")
Set NS = ThisOutlookSession.Session
Set Folder = NS.PickFolder
For Each MailObject In Folder.Items
If MailObject.Class = olMail Then
For Each RecipientObject In MailObject.Recipients
If RecipientObject.Address Like "*@*" Then
Debug.Print RecipientObject.Name, RecipientObject.Address
End If
Next
End If
Next
Set OlApp = Nothing
Set MailObject = Nothing
Set RecipientObject = Nothing
End Sub


Ivan


"Ken Slovak - [MVP - Outlook]" wrote in message
...
Get the Recipients collection of the mail item and iterate that
collection. You can harvest whatever information you want from each
Recipient (whatever is available on that object).

When adding contacts using code you will not get any warning dialogs if
you try to add a duplicate contact. So any code must search in the
Contacts to see if such a contact already exists. How you determine a
duplicate is up to you. Names can be slightly different (Richard, Rich,
Ricky) and so on, so you have to account for that.

It's somewhat more complicated than it sounds like it would be.

--
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


"Ivan" wrote in message
...
Hello

I'm using Outlook 2007 on Exchange and I'm having an email with a huge
amount of recipiens in the To and Co lines and I woul like to collect
these addresses into one of the subfolder of my Contacts folder.

OK, I can copy one email address at a time if I select only one address,
then pick out the "Add to Outlook Contacts" command from the mouse right
click menu. Evidently is this procedure more than retardatory.

If I select two or more addresses from any of both lines, then there
isn't any such "Add to Outlook Contacts" command on the content menu and
I can only copy the selected addresses to clipboard. As I can see nad
understand only the display name parts of the addresses are copied to
cipboard and these data are without real address not useful for me.

I'm sure that it should be some way to do this with VBA code. Could
anybody help me with a piece of code or a hint?

Ivan






 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract delimted list of email addresses from a distribution list? Vorv Outlook - Using Contacts 7 July 31st 08 11:13 PM
How do I extract and save a list of email addresses in Outloook? Grady Outlook - General Queries 2 March 25th 08 11:10 AM
how to extract email addresses from outlook express using php...please help.. vidya Outlook - General Queries 2 July 31st 07 10:48 AM
Extract email addresses from Distribution LIst in Global Address List tthomas Outlook and VBA 2 June 22nd 06 12:02 AM
Program to "extract" email addresses from OE? David Baxter Outlook Express 4 May 13th 06 06:32 PM


All times are GMT +1. The time now is 08:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.