office interop - Reply twice from outlook add in itemadd event -
i need reply twice outlook add-in item_add event, once mail arrives , once more after processing. code registered callback looks below:
void items_itemadd(object item) { outlook.mailitem mail = (outlook.mailitem)item; outlook.mailitem reply = mail.reply(); // add stuff reply body , subject reply.send(); marshal.releasecomobject(reply); // processing few seconds reply = mail.reply(); // update reply body , subject reply.send() // release reply object }
the problem have 2 replies sent out @ end after processing complete. there way send first reply , not wait till end?
note, run code event handler. handler should return control flow outlook process replies.
you can try use syncobjects property of namespace class force synchronization.
public sub sync() dim nsp outlook.namespace dim sycs outlook.syncobjects dim syc outlook.syncobject dim integer dim strprompt integer set nsp = application.getnamespace("mapi") set sycs = nsp.syncobjects = 1 sycs.count set syc = sycs.item(i) strprompt = msgbox("do wish synchronize " & syc.name &"?", vbyesno) if strprompt = vbyes syc.start end if next end sub