Outlook VBA - Move to folder - Body text -


i tried create script searches body text , sender name incoming email , if true move email subfolder.

i tried add code thisoutlooksession not working.

public sub mailtofolder(item outlook.mailitem)      dim mynamespace outlook.namespace     dim myinbox outlook.mapifolder     dim mydestfolder outlook.mapifolder      set mynamespace = application.getnamespace("mapi")     set myinbox = mynamespace.getdefaultfolder(olfolderinbox)      set mydestfolder = myinbox.folders("xtest")      if instr(item.body, "test123") > 0 , item.sendername = "jon"          item.move mydestfolder      end if      set mydestfolder = nothing     set myinbox = nothing     set mynamespace = nothing  end sub 

any ideas made fault?

your "item" far not set. if wish apply opened e-mail, e.g.

set item=application.activeexplorer.selection.item(1) 

if wish loop through mails in folder, need that:

set mydestfolder = myinbox.folders("xtest") each mailitem in mydestfolder.items '  ... magic next mailitem 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -