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

Status
Not open for further replies.
I

Ivan

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
 
K

Ken Slovak - [MVP - Outlook]

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.

"Ivan" <ivan@nekje.si> wrote in message

news:%23oaSFxCuJHA.4632@TK2MSFTNGP06.phx.gbl...
> 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

>
 
I

Ivan

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
<kenslovak@mvps.org> wrote in message

news:ermpdPFuJHA.5172@TK2MSFTNGP04.phx.gbl...
> 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.

> >

>

> "Ivan" <ivan@nekje.si> wrote in message
> news:%23oaSFxCuJHA.4632@TK2MSFTNGP06.phx.gbl...
> > 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
>

>
>>

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
S Unable to extract text from an Outlook email message Using Outlook 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
K Extract email address from body and auto-reply outlook Using Outlook 1
K Extract email to excel from a specific sender Outlook VBA and Custom Forms 3
O VBA to extract email (fields and body) to Excel Outlook VBA and Custom Forms 14
B Extract Dates for Appointment Item in Body of email Outlook VBA and Custom Forms 10
K extract certain text from an Outlook Email Message Outlook VBA and Custom Forms 2
H Extract emails from Outlokk 2007 email body Using Outlook 0
R Saving Outlook Email As Text File Extract Outlook VBA and Custom Forms 2
M Extract "Date sent" from emails (saved to folder using drag and drop) Outlook VBA and Custom Forms 1
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
N Extract Outlook emails to excel Outlook VBA and Custom Forms 2
T Extract Data From Outlook Tasks Using Outlook 0
T Extract Data From Outlook Tasks Using Outlook 0
V extract users of a particular department Outlook VBA and Custom Forms 1
J Outlook 2013 Extract Flag Completed dates to Excel Macro Outlook VBA and Custom Forms 16
S How to extract mail items from multiple folders and shared mailboxes? Outlook VBA and Custom Forms 0
R Trying to extract information between two symbols from outlook subject Using Outlook 2
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
D Need to extract a line from a word attachment, and add it to the subject line Outlook VBA and Custom Forms 3
E Extract excel files from outlook Outlook VBA and Custom Forms 2
D VBA Script to extract text matching specific criteria Outlook VBA and Custom Forms 1
M Extract text in existing message body for use in newmail items Using Outlook 17
M HELP--Extract Data from 2003 outlook transfer to excel spreadsheet Using Outlook 1
M VBA Code to extract data from an Outlook Form Using Outlook 0
M Extract attachments with a script Using Outlook 0
M HELP - Can't open outlook... How can I extract my Emails that I had in folders Using Outlook 3
K Extract Global Address List Using Outlook 1
N Programming to extract automatically extract attachments Outlook VBA and Custom Forms 3
S How to extract outlook calendar data. Outlook VBA and Custom Forms 3
? outlook attachment Extract File ??? Outlook VBA and Custom Forms 1
N How to extract date and time stamp from messsages Outlook VBA and Custom Forms 6
V Extract Subject,Sent From, Message from mailbox to Excel Outlook VBA and Custom Forms 5
S Automatically extract attachments? Outlook VBA and Custom Forms 1
A Links in email getting error message about group policy Using Outlook 4
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 3
J Recommendations for Outlook Duplicate Email Remover Using Outlook 6
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
V Can one change the formatting of email title blocks? Using Outlook 0
P default font when sending email from browser Using Outlook 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
B IMAP server rejects sent email - cannot deliver messages Using Outlook 2
TedSch Small vba to kill political email Outlook VBA and Custom Forms 3
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Email notifications changed with Outlook 2021 Using Outlook 8

Similar threads

Top