How to call Outlook's Desktop Alert from VBA Code -
i have outlook 2003 running on win xp. desktop alert turned on , running smoothly.
but created vba macro sorts incoming emails several different folders (via item_add event in thisoutlooksession). somehow stopped desktop alert showing.
is there way call desktop alert vba code manually? maybe function of sorts.
p.s: can't sort emails through rules, that's not option
basically i'm looking regex 6 digit code in email
code (sorry, it's bit of patchwork other pieces of code found on internet
option explicit private withevents olinboxitems items private sub application_startup() dim objns namespace set objns = application.session set olinboxitems = objns.getdefaultfolder(olfolderinbox).items set objns = nothing end sub private sub olinboxitems_itemadd(byval item object) on error resume next dim targetfolder outlook.mapifolder dim myname string dim reg1 regexp dim m1 matchcollection dim m match set reg1 = new regexp myname = "[myname]" ' \s* = invisible spaces ' \d* = match digits ' \w* = match alphanumeric reg1 .pattern = "\d{6}" .global = true end if (instr(item.to, myname) or instr(item.cc, myname)) ' if mail sent or cced me if reg1.test(item.subject) set m1 = reg1.execute(item.subject) each m in m1 ' m.submatches(1) (\w*) in pattern ' use m.submatches(2) second 1 if have 2 (\w*) set targetfolder = getfolder([folderpath]) ' function returns targetfolder exit next end if if not targetfolder nothing item.save item.move targetfolder end if end if end sub
many thanks
the outlook object model doesn't provide managing notifications. instead, may consider developing add-in instead can use third-party components allows imitate buit-in behavior. example, take @ raddesktopalert component.
see walkthrough: creating first application-level add-in outlook more information.
Comments
Post a Comment