vba - Script to create a follow up action on an email message in Outlook -


i 2 messages everday. second message must arrive within 3.5 hours; if not, have start figuring out went wrong second process kept email getting sent.

here's i'd see happen.

  1. message 1 arrives
  2. a rule executes , flags message follow-up (or really) 3.5 hours time.

there's "run script" option in outlook's rules wizard use trigger script.

bonus points:

3 . when second email arrives, clears follow-up flag first message.

here's did:

sub myrule(item outlook.mailitem)    msgbox "mail 1 has arrived: " & item.subject    dim newmail outlook.mailitem    set newmail = outlook.createitem(olmailitem)    newmail.to = item.to    newmail.subject = "!!!start looking issues!!!!"    newmail.body = "something might have gone wrong process.. did not receive closing mail " + item.subject + " received on " + item.receivedtime    newmail.deferreddeliverytime = dateadd("h", 3.5, now)    newmail.send end sub 

this mail sits in outbox 3.5 hours , gets sent.

this works if keep outlook running 3.5 hours after first mail. till when try close outlook, there items in outbox not sent. can safely ignore warning, make sure have outlook running afterwards.

(some of code written , tested in outlook. body , subject part have typed outside vb editor. might have resolve minor errors.)

edit:: bonus points..

sub myruleformessagetwo(item outlook.mailitem)     dim myitem outlook.mailitem     set outboxitems = application.session.getdefaultfolder(olfolderoutbox).items     set myitem = outboxitems.getfirst     while not (myitem nothing)         if myitem.subject = "!!!start looking issues!!!!"             myitem.delete             exit         end if         set myitem = outboxitems.getnext     loop end sub 

you can play around matching criteria if expect more 1 message sitting in outbox , want delete one.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -