Consulting

Results 1 to 2 of 2

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

  1. #1
    VBAX Newbie
    Joined
    Aug 2014
    Posts
    4
    Location

    Move emails with a month in the subject line to a sub folder representing said month?

    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!!

    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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •