Solved

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

Posted on 2013-01-04
20
253 Views
Last Modified: 2013-02-02
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
Comment
Question by:mayamp
  • 12
  • 6
20 Comments
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 

Author Comment

by:mayamp
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 

Author Comment

by:mayamp
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 

Author Comment

by:mayamp
Comment Utility
Hello gowflow,
the fields I want to include are: sender name; date; subject

regards
mayamp.
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
ok great will back shortly and sorry again for this looong laps.
gowflow
0
 
LVL 29

Assisted Solution

by:gowflow
gowflow earned 500 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Any chance to hv tried the proposed solution ?
gowflow
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Again any chance to hv tried the solution ?
gowflow
0
 

Author Comment

by:mayamp
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
replace that line
Set oApp = New Excel.Application

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

save the workbook and try again.
gowflow
0
 

Accepted Solution

by:
mayamp earned 0 total points
Comment Utility
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
 

Author Comment

by:mayamp
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This video teaches viewers about errors in exception handling.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now