Monday 15 June 2015

vba move email to folder if subject is like? -



vba move email to folder if subject is like? -

i'm using next code move emails inbox folder called supplier. works if subject 'introduction' not if subject 'my introduction'

what want add together line says if subject or body 'introduction' or 'introduce' or 'supply' etc...

also have multiple accounts in outlook, @ moment code works default account, want work business relationship called 'purchasing@hewden.co.uk', there way can alter this? 'supplier' folder within inbox of purchasing@hewden.co.uk business relationship , want move email inbox supplier folder.

sub moveitems() dim mynamespace outlook.namespace dim myinbox outlook.folder dim mydestfolder outlook.folder dim myitems outlook.items dim myitem object set mynamespace = application.getnamespace("mapi") set myinbox = mynamespace.getdefaultfolder(olfolderinbox) set myitems = myinbox.items set mydestfolder = myinbox.folders("supplier") set myitem = myitems.find("[subject] = 'introduction'") while typename(myitem) <> "nothing" myitem.move mydestfolder set myitem = myitems.findnext wend end sub

i know question asked code can done much easier through utilize of rules. if reply not wanted delete it.

anyway should read on this , this larn rules, awesome. you're going want create new rule , have filter based on keyword within subject line, can write 'introduction' , outlook know word.

you have specify email goes and, in case, need specify kind of notification (if any) displayed when new mail service arrives.

all of should available under rules -> create new rule.

vba email outlook

No comments:

Post a Comment