简体   繁体   中英

How to add programmatically information to an email using VSTO Outlook?

We are currently developing an addin that interact with the end user visually to give some informations, and we wanted to use Mailtips but apparently it is not possible from what we saw

Nevertheless, is it possible to have something similar or to mimic this kind of tip (2nd sshot would be ideal)..

Option 1: https://i.stack.imgur.com/vcQYb.png

Option 2: https://i.stack.imgur.com/7k19w.png

We also looked and form region but that would be the last option, ideal would be to have the tooltip in 2nd screenshot to display a small message to help user (any clue appreciated).

We were also looking for a function to disable links in the body (as the junk filter does), but also no chance finding this through the documentation (maybe internal procedure)

Looking everywhere for documented elements...

On the screenshot you have seen a standard Outlook notification and MailTips - that is a feature of Exchange, not Outlook.

We also looked and form region but that would be the last option, ideal would be to have the tooltip in 2nd screenshot to display a small message to help user (any clue appreciated).

The Outlook object model doesn't provide anything for that, there is no built-in property or method for that. The only possible option is to use a form region where you could put your custom UI at the bottom of the standard form/window in Outlook. The Adjoining layout available for Outlook form regions appends the form region to the bottom of an Outlook form's default page. So, if you want to place the form at the top you need to use Windows API functions to subclass Outlook windows or consider using the Advanced Outlook view and form regions where the top layout is provided out of the box.

Also you may consider developing a web add-in for Outlook where you could set up notification items programmatically from the add-in, see Office.NotificationMessages interface for more information. For example:

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml
const id = $("#notificationId").val();
const details =
  {
    type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
    message: "Non-persistent informational notification message with id = " + id,
    icon: "icon1",
    persistent: false
  };
Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);

See Build your first Outlook add-in to get started quickly on that.

We were also looking for a function to disable links in the body (as the junk filter does), but also no chance finding this through the documentation (maybe internal procedure)

You need to process the message body on your own. The Outlook object model doesn't provide any property or method for that out of the box.

The Outlook object model supports three main ways of customizing the message body:

  1. The Body property returns or sets a string representing the clear-text body of the Outlook item.
  2. The HTMLBody property of the MailItem class returns or sets a string representing the HTML body of the specified item. Setting the HTMLBody property will always update the Body property immediately.
  3. The Word object model can be used for dealing with message bodies. See Chapter 17: Working with Item Bodies for more information.

You can add a special MAPI property (used by Web addins, DASL name "http://schemas.microsoft.com/mapi/string/{A98A1EF9-FF40-470B-A0D7-4D7DCE6A6462}/WebExtNotifications" ) to show the notification banner.

Something along the following lines (VBA, you'd need to deselect and select again the currently selected message to see the change):

    notificationXml = "<?xml version=""1.0""?>" & vbCrLf & _
    "<Apps>"& vbCrLf & _
    "  <App id=""00000000-0000-0000-0000-000000000000"">"& vbCrLf & _
    "    <Notifications>"& vbCrLf & _
    "      <Notification key=""notification"">"& vbCrLf & _
    "        <type>0</type>"& vbCrLf & _
    "        <message>Test notification&#13;with two lines</message>"& vbCrLf & _
    "      </Notification>"& vbCrLf & _
    "    </Notifications>"& vbCrLf & _
    "  </App>"& vbCrLf & _
    "  <App id=""00000000-0000-0000-0000-000000000001"">"& vbCrLf & _
    "    <Notifications>"& vbCrLf & _
    "      <Notification key=""notification"">"& vbCrLf & _
    "        <type>0</type>"& vbCrLf & _
    "        <message>Another notification</message>"& vbCrLf & _
    "      </Notification>"& vbCrLf & _
    "    </Notifications>"& vbCrLf & _
    "  </App>"& vbCrLf & _
    "</Apps>"
    
    set msg = Application.ActiveExplorer.Selection(1)
    msg.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/string/{A98A1EF9-FF40-470B-A0D7-4D7DCE6A6462}/WebExtNotifications", notificationXml
    msg.Save

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM