Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Outlook search for items with certain category and copy items to new excel

Hi, Can anyone help me with this one: I want to make a macro in outlook to search the inbox for emails classified with a specific category and then create a new spreadsheet in excel and copy some atributes of the matching emails (recepient, subject, etc).
regards !
0
mayamp
Asked:
mayamp
  • 12
  • 6
2 Solutions
 
gowflowCommented:
yes sure. why would you do the macro in Outlook ? We can do it in Excel to read emails in outlook would that be fine with you ? and second we need to know what is the mail folder you want to search for the Inbox ? or an other ? if an other I need the full path of your folder or a snapshot of the folders from outlook. Then I need to know what is the category or maybe is it easier to find the email thru a specific subject ?
Will wait for your reply to ellaborate more. Don't give up there is a solution for you ... see this msg was left out as neglegted.
gowflow
0
 
mayampAuthor Commented:
Hello, thanks for the help.
I was thinking in outlook because that report would be more direct (for example a button in the tools ribbon)  when I'm checking the inbox for new mails. The macro in excel directly also would be great !. The folder could be the default Inbox or a Personal folder: "Jan 13 Personal"
The Category is "To-do". I prefer to assign categories instead of modifying the subject.


Thanks
regards,
mayamp
0
 
gowflowCommented:
So what is it now Outlook or Excel ?
I personally perfer Excel as when we are in Outlook will need to know what file to save info in and where to be located and we add more info to remeber the file and updated it is a bit more than what this question could hold. If you insist on Outlook I do not hv a slight problem in the countrary I hv developped solutions in outlook but then lets agree in splitting this into 3 parts:

1) first being the mechanics behind selecting folders to monitor
2) second being the setup of Excel file to save data to and hv it remebered by outlook so everytime you run outlook it has the settings for that file and will open it and append data to it after last record there (all this done thru registry)
3) thrid the engine which is finding the emails in in the specific folders that belong to specific categories and saving the required fields.

So your choice Excel or Outlook in both cases I suggest a 3 questions approach this way you have a solution that is quite flexible to you and allows you to change any time you want the folder to monitor and also hv the posiblility to choose the Excel file to update data to and change it whenever you want.

Let me know your though on this approach.
gowflow
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
mayampAuthor Commented:
Thanks gowflow,
I would prefer outlook. I agree to separate the problem in 3 parts.

1. The folders to make the search are the Inbox and a personal folder named "Jan 13 Personal". This because some emails with the "to-do" category are in the default inbox and others are in the personal folder.
2. I don't need to keep record of last "queries" in the excel so its not necessary to use the same excel each time. When the report is run, I want the macro to create a new excel book and copy the email info to it. Then I can save it or delete the book after use.

regards
mayamp
0
 
gowflowCommented:
ok fine so you will need to remember the 3 parts as will use this question to deal with part 1 and you can once it is finished as a related question and put part2 and give it the coresponding exlanation and put this question as related. etc...
Will revert with first part later on
gowflow
0
 
gowflowCommented:
Sorry for this laps due to being caught in several issues.

I am looking at the threads here and ready to provide you with something to start with but hv a small question first:

You say in your last post:
I want the macro to create a new excel book and copy the email info to it.

What is the 'info' you want to copy to the Excel ??? the body of the email ? the whole email ? certain fields can you be specific so I build it in hte first macro as it is ready but missing the specifics ??

Await for your answer.
gowflow
0
 
mayampAuthor Commented:
Hello gowflow,
the fields I want to include are: sender name; date; subject

regards
mayamp.
0
 
gowflowCommented:
ok great will back shortly and sorry again for this looong laps.
gowflow
0
 
gowflowCommented:
Ok here it is, I hope it meet your requirement. Open the file and follow hte instructions in the file.
You need to add a reference to Microsoft Outlook Object Library in vba tools menu select references and find this item tick it and close and save the workbook then try it enabling macroes.

Let me know results.
gowflow
Email-Extract.xlsm
0
 
gowflowCommented:
Any chance to hv tried the proposed solution ?
gowflow
0
 
gowflowCommented:
Again any chance to hv tried the solution ?
gowflow
0
 
mayampAuthor Commented:
goflow, sorry for the delay in the response.
when running the macro, excel crashes at the following line code: "Set oApp = New Excel.Application"

regards
0
 
gowflowCommented:
replace that line
Set oApp = New Excel.Application

BY this line
Set oApp = CreateObject("Excel.application")

save the workbook and try again.
gowflow
0
 
mayampAuthor Commented:
thanks goflow. It didn't work that way, but I made a little change that work. I replace
Set oApp = CreateObject("Excel.application") with just
Workbooks.Add
Set WBResult = ActiveWorkbook

thans a Lot !
0
 
mayampAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for mayamp's comment #a38826463

for the following reason:

The solution is from the expert, I made a little change in the solution that adapted better to my problem.
0
 
gowflowCommented:
Sorry don't know if this was your intention or you simply did a mistake.
You closed that question awarding yourself the answer meaning 0 point for giving you a file that works with a full solution. Is that what you wanted or it was simply a mistake ?

gowflow
0
 
gowflowCommented:
mayamp
I would appreciate your reply to my comment above as feel something is not correct here in the closing of this question.

gowflow
0
 
gowflowCommented:
Sorry to ask for Moderator's intervention in here as feel somehow that the asker did not make the correct choice in closing this question. I provided a full working solution and somehow something did not work for him and substituted 1 line by an other and closed that question as  you can see with Zero points.

Would appreciate you ask asker if this was his real intention as have put 2 comments and he did not reply.

Tks your attention.
gowflow
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now