vbaoutlookreply

Changing the email text in an "have server reply using specific reply" action with vba


I have the following rule in outlook: have server reply using specific reply rule

My aim is now, to change the email text that gets send by the action with a vba script. The data we send out as a respones changes daily, so at the moment we have to change it by hand. I tried now many things, but don't come really to the possibility to change the text with vba.
I'm also not sure if i can get it with olRuleActionServerReply (because it has no item oder similar when i watch this action) or with olRuleActionTemplate... I'm happy for any hint in this situation. Thank you in advance!

I tried to find anything in the documentation but didn't find anything helpful.


Solution

  • There is no way to use a dynamic reply with a different text used for the message body. You need to set up a different rule for that or handle incoming emails in VBA without rules involved.

    For example, you could handle the NewMailEx event of the Application class where you could check the incoming email and prepare the response and send it automatically. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. Use the Entry ID to call the NameSpace.GetItemFromID method and process the item.