PDA

View Full Version : Move emails with a month in the subject line to a sub folder representing said month?



bangy
10-02-2014, 01:54 PM
Hello,

I have spent all day tinkering and joining together scripts that people have generously offered on this site to make the macro i am in need of and... i have failed!!:banghead:

So my vision is, an email is received in my inbox folder on Outlook. The email will always have a month in the subject field written in full (e.g. January, February etc). Subfolders will be contained within the inbox folder labelled as the months of the year. The macro i have tried to form will, when run, search the inbox folder and transfer all the emails with a subject field containing "January" into the subfolder "January", all the emails with a subject field containing "February" into the subfolder "February"...and so on for the remaining 10 months of the year.

Any help with a script would be very much appreciated. To have a macro that could save so much time would be amazing!!

The Microsoft Outlook version is 2010 and i am using Windows.

Mike

westconn1
10-02-2014, 02:41 PM
to get the monthname of folder, you can try like

Function getmonth(subject) As String
For mnth = 1 To 12
mnthname = Format(DateSerial(Year(Now), mnth, 1), "mmmm")
If InStr(1, subject, mnthname, vbTextCompare) > 0 Then getmonth = mnthname: Exit Function
Next
End Function

' call like

folder = getmonth(msg.subject)
from within some procedure
if you are going to move emails from a collection (folder) from within a loop you must work from the bottom like

for i = msgs.count -1 to 1 step - 1