-2

I am curious to know if this is possible.

I receive invoices daily. I have a batch file which creates a folder everyday displayed as (mm - dd - yyyy).

My goal is to create a macro which moves emails to their designated folders, which is located on my hard drive, everyday.

For example, all email received today would be moved to a folder labeled 05-01-2015. And then emails I received tomorrow would go into a folder labeled 05-02-2015. Mind you that the way the folders are being created is through a batch file which will run everyday.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
novicevba
  • 81
  • 10
  • Yes that's definitely possible. – Tim Williams May 01 '15 at 16:37
  • How would one go abouts in doing so? I have seen macros to move emails, but I haven't seen any based on a daily occurrence. – novicevba May 01 '15 at 19:22
  • This is a Q & A site not a forum. Pure code-writing requests are off-topic on Stack Overflow. Show what you have tried, the relevant code and the specific issues you are having. You may find http://stackoverflow.com/help/mcve and http://stackoverflow.com/help useful. Edit the question to add details. If it cannot be salvaged then consider deleting this question. As it stands now it can only gather downvotes which impacts your ability to ask questions. http://meta.stackoverflow.com/questions/258757/how-can-i-understand-why-am-i-receiving-a-warning-that-i-could-be-blocked – niton May 02 '15 at 10:09

1 Answers1

1

To process incoming emails you need to handle the NewMailEx event or create a rule which can run a VBA macro sub. The VBA macro sub should look like the following one:

public sub test(mail as MailItem)
   ' do whatever you need
end sub

In the code you can check out the current date and find the corresponding folder, then move the incoming mail item to the target folder.

I'd suggest starting from the Getting Started with VBA in Outlook 2010 article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45