Forum

Extract Email Addre...
 
Notifications
Clear all

Extract Email Address from Outlook messages

19 Posts
3 Users
0 Reactions
442 Views
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi,

Could you please help me.

I have a lot of outlook messages in folder in my PC and I want to extract these "Subject, Received Date/Time, To, CC, Message Path"

Example:

Subject: Test

Received Date/Time: Sun 5/31/2020 9:24 AM

To: [email protected]

CC: [email protected]

Message Path: E:messagesCase (# 44347_2) Inquiry.msg

I found attached macro in myonlinetraininghub.com and I need your help to update it.

 

Thanks;

Marsil

 
Posted : 02/06/2020 7:00 pm
(@purfleet)
Posts: 412
Reputable Member
 

Hello

Are the emails saved as seperate .msg in a  folder on your harddrive or are they still in outlook?

 
Posted : 03/06/2020 1:08 am
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Purfleet,

 

Thank you for fast response.

Yes I have all messages in Outlook.

Note: I have two account in my outlook and I want to get data for specific folder, Please check attached image.

Grateful for your support..

Thanks;

Marsil

Outlook-1.png

 
Posted : 03/06/2020 6:15 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Marsil.

See attached file. From your image it looks like you want emails that are not in your default email account.  In which case you need to change this line in the VBA

Set Folder = OutlookNS.Folders("NAME OF EMAIL ACCOUNT").Folders("Inbox")

Insert the NAME of your account, NOT the email address.  So if your account is in the name Marsil Sarvis then insert that.

I don't understand what you are referring to when you talk about the Message Path.  Each email will be stored within the mailbox not separately on the hard drive as .msg files - which is what Purfleet was asking about too.

Regards

Phil

 
Posted : 05/06/2020 12:35 am
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil,

I want to thank you for your continued support.

I saved it path as my target is  save all these messages in Path and send to another person to read email body and signatures then extract valuable information.

Could you please help me as I face attached issues when I try to run the macro please.

Grateful for your support..

1.png2.png

 

 

Thanks;

Marsil

 
Posted : 05/06/2020 5:53 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Marsil,

You need to set a reference to the Microsoft Outlook 16.0 Object Library in the VBA editor.  Sorry I thought you'd already done this as your first post gave me the impression you'd run the code already.

Open the Excel file, go into the VBA editor and then from the menu click Tools -> References and check the box beside the library

Regards

Phil

 

vba tools references

 
Posted : 05/06/2020 6:27 am
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil,

 

Please see attached image and I think there is something is wrong 3.pngfrom my side.

 

Thanks

Marsil

 
Posted : 05/06/2020 6:36 am
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil,

I can't see "Outlook 16.0 Object Library" in References window, please check attached image.

It is contain " missing microsoft outlook 16.0 object library"

Please can you let me know how I can add "Outlook 16.0 Object Library" in References window?

3-1.png

 

Thanks;

Marsil

 
Posted : 05/06/2020 9:01 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Guys,

Try the attached file.  I've rewritten it to use late binding so you don't need to set a reference to the Outlook library.

Cheers

Phil

 
Posted : 05/06/2020 9:33 pm
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil

It works perfectly That's a huge help - thanks!

I check macro result and I have below notes, Please take a look.

----Macro give error when it face “meeting invitation email”, please check attached image.

    If u can help me to ignore any “meeting invitation email” to let the macro complete to extract all messages.

 

-----In To & CC columns contain the display name not emails address.

      If you can update this to extract the email address not display name.

       Ex: the current result is “Marsil Sarvis” , please I need [email protected]

Thanks again. Couldn't have done it without you.

Thanks;

Marsil

 

meeting-invitation-email.png

 
Posted : 06/06/2020 9:47 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Marsil,

Try this.

regards

Phil

 
Posted : 08/06/2020 11:43 pm
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil,

Please check attached macro result.

Thanks,

Marsil

 
Posted : 09/06/2020 3:37 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Marsil,

That is a Microsoft Exchange user.  Are you connected to Exchange?

Phil

 
Posted : 09/06/2020 6:55 am
(@marsil)
Posts: 72
Estimable Member
Topic starter
 

Hi Phil,

I think yes, I run the macro from my PC and I don't open the outlook online.

Please let me know what's the issue.

 

Thanks;

Marsil

 
Posted : 09/06/2020 6:58 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Marsil,

Please see the attached file which is based on some code from https://stackoverflow.com/questions/7941191/extract-email-address-from-outlook

I can't really test this for you as I am not connected to your Exchange server and the code relies on this.

Regards

Phil

 
Posted : 11/06/2020 9:42 pm
Page 1 / 2
Share: