Question
Is it possible with an Outlook add-in to automatically reply only to certain emails/senders, based on custom logic? If so, how?
Examples
Such an add-in might send an automatic reply only to senders not in contacts, or only to senders whose email has been verified by an external service (which the add-in calls to check). This automatic reply might be:
Thanks for your email! I prioritize emails from verified senders. You can verify yourself for free here.
The sender who receives that message could then click the link and verify through the external service. Then, for future emails, the automatic reply would NOT apply to that sender.
Background
Outlook has an automatic reply option in settings, but its functionality is limited to setting a specific message for internal senders and a different one for external senders, plus choosing whether to only use the automatic reply with contacts. There's no built in ability to accomplish what's described in the examples above.
Other Questions and Answers (Possibly Relevant)
- Office-js: How I can reply automatically with Outlook Web Add-in?: This may be relevant, but it's hard to tell because the link in the answer is broken now (the answer is from almost 4.5 years ago).
- How can I edit the automatic reply in outlook using c#: Also might be relevant, but also has a broken link in the answer (which is from almost 7 years ago).
Any help would be very much appreciated!
CodePudding user response:
Outlook web add-ins are designed for running for the currently selected item. So, the user should select a particular item in Outlook to activate the add-in. Unlike VSTO where you could handle incoming emails by handling the NewMailEx event of the Application class.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID returned in the EntryIDCollection string to call the NameSpace.GetItemFromID method and process the item. 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.
As soon as you have got an instance of the incoming email you can use the MailItem.Reply method which creates a reply, pre-addressed to the original sender, from the original message.
Finally, you may find the following articles helpful:
- How To: Create and send an Outlook message programmatically
- How To: Fill TO,CC and BCC fields in Outlook programmatically
- How To: Change an Outlook e-mail message before sending using C# or VB.NET
CodePudding user response:
Outlook web add-ins currently require the context of an item to run. Event based add-ins will run in the context of an item without users having to explicitly launch an add-in to complete their tasks. However, an OnMessageSelected event, you requested is not a part of the web add-ins product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process.
Github Label: “Type: product feature request” https://aka.ms/M365dev-suggestions
