Consulting

Results 1 to 4 of 4

Thread: Macro to move based on sender to specific folder.

  1. #1

    Macro to move based on sender to specific folder.

    Hi All,

    I come to you for help.. I've dabbled just a bit with macros and have searched for days on this particular one. I ran out of rule space and I have 30+ people who send me emails daily. I'd like a macro that will allow me to run that will move the email based on the email address to that person's own folder. So essentially what a rule is already doing for me, but again I am out of rule space and cannot request additional space nor delete any previous rules at this time.

    Any help would be greatly appreciated.

  2. #2
    you can use the newmessage event to do this, so it is moved on arrival

    Private Sub Application_NewMail()
    Dim msg As MailItem, myfolder As MAPIFolder
    Set myfolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set msg = myfolder.Items(myfolder.Items.Count)  ' should get the newest file
    fldr = msg.SenderName    ' you can change this to any suitable property that can match your folder name
    msg.Move myfolder.Folders(fldr)   '  assumes that named folders are sub folders of inbox, or change to suit like
    'msg.move myfolder.parent.folders(fldr)
    
    End Sub

  3. #3
    Quote Originally Posted by westconn1 View Post
    you can use the newmessage event to do this, so it is moved on arrival

    Private Sub Application_NewMail()
    Dim msg As MailItem, myfolder As MAPIFolder
    Set myfolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set msg = myfolder.Items(myfolder.Items.Count)  ' should get the newest file
    fldr = msg.SenderName    ' you can change this to any suitable property that can match your folder name
    msg.Move myfolder.Folders(fldr)   '  assumes that named folders are sub folders of inbox, or change to suit like
    'msg.move myfolder.parent.folders(fldr)
    
    End Sub

    Thank you for the help.. Where exactly do I put the email address from the person?

    Thank you

  4. #4
    Where exactly do I put the email address from the person?
    i used sendername, which will either contain the email address or the address book name of the sender
    depending on the structure of the folder name you may have to parse the email address, to return the exact folder name
    if the folder name does not exist an error will occur on .Move, so you would need to check if the folder exists before calling .Move, in case you receive emails from senders who are not in your group of folders

Posting Permissions

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