vba - How to filter items sendername from Items_ItemAdd Events? -


private withevents items outlook.items  private sub application_startup()   dim ns outlook.namespace   dim folder outlook.mapifolder    set ns = application.getnamespace("mapi")   set folder = ns.getdefaultfolder(olfolderinbox)   set items = folder.items end sub  private sub items_itemadd(byval item object)   if typeof item outlook.mailitem     printattachments item   end if end sub 

i made rule outlook automatically print incoming email attachment, exception of few coworkers'email.

if stop rule macro not working on own(supposing should,code error?) if rule's enabled every email attachment printed twice.

one every page , 1 first page. there way work around this? kindly assist , in advance!

work items.restrict method (outlook) exclude senders name. filtering items

example

private withevents items outlook.items private sub application_startup()     dim olns outlook.namespace     dim inbox  outlook.mapifolder     dim filter string      filter = "@sql=" & " not (urn:schemas:httpmail:fromname" & _                        " '%ming lian%' or " & _                              "urn:schemas:httpmail:fromname" & _                        " '%0m3r 0mr%')"       set olns = application.getnamespace("mapi")     set inbox = olns.getdefaultfolder(olfolderinbox)     set items = inbox.items.restrict(filter)  end sub 

make sure update %ming lian% correct name , don't need outlook rule

items.restrict method alternative using find method or findnext method iterate on specific items within collection. find or findnext methods faster filtering if there small number of items. restrict method faster if there large number of items in collection, if few items in large collection expected found.


filtering items using string comparison dasl filters support includes equivalence, prefix, phrase, , substring matching. note when filter on subject property, prefixes such "re: " , "fw: " ignored.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -