Coder Social home page Coder Social logo

officedev / outlook-add-in-on-send Goto Github PK

View Code? Open in Web Editor NEW
34.0 24.0 31.0 141 KB

Learn how to check for restricted words in an Outlook email message body, add a recipient to the CC line and check that there is a subject in the email on send.

License: MIT License

CSS 12.33% JavaScript 87.67%

outlook-add-in-on-send's Introduction

page_type products languages extensions
sample
office-outlook
office-365
javascript
contentType technologies createdDate
samples
Add-ins
3/20/2017 11:55:13 PM

Outlook add-in on send code sample

Learn how to check for restricted words in an Outlook email message body, add a recipient to the CC line and check that there is a subject in the email on send.

Note:

Table of Contents

Change history

April 2017

  • Initial version.

Prerequisites

  • A trusted web server to host the sample files. The server must be able to accept SSL-protected requests (https) and have a valid SSL certificate.
  • An Office 365 email account.
  • Enable the on send feature - by default, the on send functionality is disabled. Add-ins for Outlook on the web that use the on send feature will run for users who are assigned an Outlook on the web mailbox policy that has the OnSendAddinsEnabled flag set to true. Administrators can enable on send by running Exchange Online PowerShell cmdlets. To learn what cmdlets to run, see Installing Outlook add-ins that use on send

Configuring and installing the sample

  1. Download or fork the repository.

  2. Open app.js. In addCCOnSend function, change [email protected] to your own email address.

  3. Deploy the add-in files to a directory on your web server. The files to upload are app.js and index.html.

  4. Open Contoso Message Body Checker.xml and Contoso Subject and CC Checker.xml manifest files in a text editor. Replace all instances of https://localhost:3000 with the HTTPS URL of the directory where you uploaded the files in the previous step. Save your changes.

    For more information about:

Upload the manifests

  1. Logon to Outlook Web App.
  2. Click Settings (the gear cog in the upper right corner of the page) to open the Settings page (as shown in the following screenshot).

The settings page

  1. In Your app settings section of the Settings page, choose Mail.
  2. In the Options page, select General and then Manage add-ins (as shown in the following screenshot).

The manage add-ins page

  1. On the Manage add-ins page, click the '+' icon, select Add from file. Browse to the Contoso Message Body Checker.xml manifest file included in the project. Click Next, then click Install. Finally, click OK.
  2. Repeat step 5 to install Contoso Subject and CC Checker.xml manifest file.
  3. Return to the Mail view in Outlook Web App.

Run the add-in

Subject and CC Checker

  1. Compose a new Outlook Web App email message.
  2. Leave the subject line blank.
  3. Add a recipient in the To line.
  4. Click Send.
  • A carbon copy is added to the CC line. In this sample, it's [email protected].
  • The email is blocked from being sent and an error message displayed on the information bar to notify sender to add a subject. (as shown in the following screenshot).

The subject and CC checker information bar

  1. Add a subject line.
  2. A [Checked]: is added to the front of the subject line and email is sent.

Message Body Checker

  1. Create a new Outlook Web App email message.
  2. In the body of the message, type blockedword, blockedword1 or blockedword2. (These are the array of restricted words in the app.js file of the checkBodyOnlyOnSendCallBack function).
  3. Add a recipient in the To line.
  4. Click Send.
  • The email is blocked from being sent because of blocked words found in the message body.
  • An error message displayed on the information bar to notify sender of blocked words found (as shown in the following screenshot).

The message body checker information bar

  1. To send the email, remove the blocked words.

Questions and comments

We'd love to get your feedback about this sample. You can send your feedback to us in the Issues section of this repository.

Questions about Microsoft Office 365 development in general should be posted to Stack Overflow. If your question is about the Office JavaScript APIs, make sure that your questions are tagged with [office-js] and [API].

Additional resources

Copyright

Copyright (c) 2016 Microsoft Corporation. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

outlook-add-in-on-send's People

Contributors

davidchesnut avatar exextoc avatar lauragra avatar lindalu-msft avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar o365devx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

outlook-add-in-on-send's Issues

On-send disabled by default? Not in our experience

By default, on-send functionality is disabled. Administrators can enable on-send by running Exchange Online PowerShell cmdlets.

This does not appear to be accurate for Office 365. On-send is enabled by default.

outlook Addin says "is working on your request" and doesnt finish

I deployed an outlook addin using sideloading and the webserver URL is accessible if i try from a web browser.
But when I test it using outlook application / outlook web, it says

"myaddin is working on your request" for some time and then displays
"addin couldnt complete. Please try sending this message later. Dismiss this message"

How to debug / check logs to see why the request is not sent properly to webserver ?

On-Send Not Triggering on Windows Outlook 2016

Using the on-send add-in tutorial I'm attempting to configure execution on send in Windows Outlook 2016.

I've followed the instructions configuring the Disable send when web extensions can't load setting in gpedit.msc

When I create and send an email containing blockedwork, the event will trigger properly on Office365 web, but not on the windows app. I'm wondering if there additional steps involved in getting the extension working on Windows native?

Thanks,

Anthony

mailboxItem is always empty.

I've been able to get the ItemSend event to fire my function, at the moment I currently block the message from sending just to check that I am getting all of the message data but it is always empty.

In the manifest:
<FunctionFile resid="functionFile" /> <ExtensionPoint xsi:type="Events"> <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="MessageSent" /> </ExtensionPoint>

In the FunctionFile:

`Office.initialize = function (reason) {
$(document).ready(function () {
mailboxItem = Office.context.mailbox.item;
console.log("Page Ready");
console.log(reason);
});
};

function MessageSent(event) {
console.log(Office.context.mailbox.item.to);
console.log(event);
//stop the message from sending to get the data
//event.completed({ allowEvent: true});
}`

All I get from the console for the 'to' field I get this:
r.ComposeRecipient {_type$p$0: 0, _propertyName$p$0: "to"} _propertyName$p$0: "to" _type$p$0: 0 __proto__: addAsync: ƒ (n) constructor: ƒ (n,t) getAsync: ƒ () setAddHelper: ƒ (n,t,i) setAsync: ƒ (n) _propertyName$p$0: null _type$p$0: 0 __proto__: Object

Anyone have any ideas why I cannot retrieve the message data?

image

On Send won't work with dialog

I'm using the on send event with Outlook Add Ins to show a dialog box confirming if the user wants to log the email or not. But it seems to be incompatible to use the On Send with dialogs. When I can get an email to send the send button becomes disabled, this can also happen on no and cancel. I don't understand why there isn't a basic template like the discard dialog that pops up. I just need to modify that for my needs.

Before I post all of the code has anyone else had this problem?

Finally have On Send working with Dialog, sort of

I can get the dialog to work with on Send, but it only works once. As soon as I go to create another message the dialog does not show and the send button is completely disabled. I guess something needs to be reset somewhere?

But surely on send gets called every time a new message is created??

The lack of documentation is extremely frustrating with On Send with Outlook and Dialogs

OnSend fired twice after attachment reminder

If I include the word "attachment" in the email body and I click Send button, OnSend event is fired once and a pop-up modal window shows up with this message:

Attachment reminder
You may have forgotten to attach a file.

with Send and Don't send buttons. If click Send, OnSend event get fired twice: 2 times after clicking Send button within attachment reminder. I was expecting only one event like the first Send (before attachment reminder pop-up).

Sample code not working on Outlook Office 365 Web App & Mac

I have tried this sample on both Outlook Office 365 Web App & Mac but it doesn't work. I can see the add-ins being added successfully but email send blocking is not happening.

I have tested the server configuration by adding the XML through a URL and via file upload.

  • Is there a different configuration scenario for Outlook Office 365?
  • What is the best way to debug add-ins and understand failures?
  • Why is this sample not working on Outlook Office 365?

Thanks !

When will feature be available for Mac and Windows?

Hi guys.
This great feature was released now nearly a year ago for OWA. Is was then send that other platforms would follow soon. I would expect it to be already available after this time. Is there any information about this? I can find it nowhere.

Thanks!
Rick

Spell Check shows up twice

The spell check is showing before the add-in captures the event and after the event is released by the AddIn.

user confirmation

I have the on-send event passing mailbox item information back to my application API but I need the user to confirm the action if for instance the user email does not exist already in our app. Something like "This user does not currently exist! Add as new user? [OK] [CANCEL].
I believe this is not possible with the notifications that are part of this example, right? I see some dialog options but have not been able to successfully merge the two projects into a single xml. Is there a notification type where you can define an action besides 'dismiss'? Or is there another project that would provide an example as I described?

Error message with wrong child element when trying to define send event

When I Try to add the OnSend Event definition in my manifest, I get an error message about a wrong child element. See attachment images. Searching for this error leads to no results. I tried to remove all other stuff but whatever I try to do, this message stays. I only have the suggested elements. Anyone any ideas? I use Visual Studio 2017

image

image

Thanks!

Regards,
Rick

OnSend feature doesn't work in Office 2016 for Windows Outlook

All other features of a normal Office Web Add In seem to work in the Office 2016 for Windows desktop version of Outlook as well. The sample application works correctly in the Office 365 Web Inbox, however it does not work in the Outlook desktop application. Is there any way to perform a function when an email is sent either in the Office 365 Web email client or the Outlook desktop application?

New OWA - onSend support

For the new owa I see the on send addin work without setting the OnSendAddinsEnabled to true , will this be a default roll out feature? And does classic web owa and new owa use different policy under the hood ?

ItemSend event is invalid

I tried to validate "Contoso Message Body Checker.xml" with "office-addin-manifest validate" command, and got the next error:

Error # 3:
Mailbox add-in containing ItemSend event is invalid.: Mailbox add-in containing ItemSend event is invalid.

  • Details: Mailbox add-in manifest contains ItemSend event in VersionOverrides which is not allowed.

I tried to search information about this but found nothing.
Where ItemSend should be? Where I can find a correct example with manifest that contains ItemSend?

On-Send in not working on the desktop side

I used the above example. In the web-side outlook, everything is very good, but in the desktop side outlook, the onsend function does not work. My outlook is Microsoft 365 commercial application version, 2102(13801.20294)

Readme content inconsistency.

It seems that readme file didn't update for such a long time.

Issue 1

It says:
"The on send feature is currently supported for Outlook on the web in Office 365 only"
But, the documentation says that it supported on mac.

Issue 2

To learn about the on send feature, see On send feature for Outlook add-ins.

Link is incorrect.

Please, update readme file.

Related issue #23

if the server goes down

What happens if the server that hosts this onSend Add in goes down? Will email sending be blocked completely? Is there a way to work around this ?

IE11 - JS Files not loading.

Outlook Add-in that we developed works Outlook for Web on Chrome with no problems, but we can't get it run on IE 11.

We get the following errors in console on IE 11:

SEC7111: HTTPS security is compromised by res://ieframe.dll/errorPageStrings.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/httpErrorPagesScripts.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/red_x.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/bullet.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/background_gradient.jpg
SEC7111: HTTPS security is compromised by res://ieframe.dll/forbidframing.htm
SEC7111: HTTPS security is compromised by res://ieframe.dll/errorPageStrings.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/httpErrorPagesScripts.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/red_x.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/bullet.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/background_gradient.jpg
We examined the network request. The server returns the HTML content but for some reason that content isn't rendered on the screen.

In HTTP Watch , I see all the JS file script tags calls are aborted.

We are looking for a solutions which we can apply to our code without needing a user to update it's IE security options. Please help! Thank you

How to detect active Extension Point?

Imagine you have this event handler combined with other Extension Points in the manifest, like Appointment Compose or Appointment Read.

How do you distinguish which is the active Extension Point in the manifest, with a single Addin?

On-send works for shared mailboxes

On-send functionality is only supported for user mailboxes in Outlook on the web, Windows, and Mac. The functionality is not currently supported for the following mailbox types and modes.
*Shared mailboxes

We aren't finding this to be the case. Is it still accurate?

Adding attendees and send doesn't work

I've tested at your example with setting the subject and send (subjectOnSendChange) and it worked fine.
But, in my case, I want to change the attendees (required / optional - does not matter) and send the Appointment.
When I'm doing that I got a notification saying 'Couldn't save event'.
I've tried with setAsync and addAsync and both not working (obviously I prefer the addAsync function).

I've attached the code and a GIF (I've made it slower for better understanding).

ezgif com-video-to-gif

var mailboxItem;

Office.initialize = function () {
mailboxItem = Office.context.mailbox.item;
};

function itemSendHandler(event) {
mailboxItem.requiredAttendees.addAsync(['[email protected]'], {asyncContext: event });
event.completed({ allowEvent: true });
}

Can you also create a manifest example for an Appointment?

I'm trying to have an on send handler assigned to a function within an addin for appointments. I strictly follow the manual, but I'm getting an error on the manifest validation

Error #1: 
Mailbox add-in containing ItemSend event is invalid.: Mailbox add-in containing ItemSend event is invalid.
  - Details: Mailbox add-in manifest contains ItemSend event in VersionOverrides which is not allowed.

My manifest.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">
  <Id>90992a37-6ac0-4e31-8f4d-c35d61ac033b</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>CKT (dev)</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  
  <DisplayName DefaultValue="Sync events with CKT Portal (dev)"/>
  
  <Description DefaultValue="Sync events of Outlook with CKT portal (dev)"/>
  
  <IconUrl DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/ckt.gif"/>
  <HighResolutionIconUrl DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/ckt-128x128.gif"/>
  <SupportUrl DefaultValue="https://ckt-d.internal.epo.org"/>

  <AppDomains>
    <AppDomain>https://ckt-d.internal.epo.org</AppDomain>
  </AppDomains>

  <Hosts>
    <Host Name="Mailbox"/>
  </Hosts>

  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.8"/>
    </Sets>
  </Requirements>

  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/taskpane.html"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <Permissions>ReadWriteMailbox</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" />
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read" />
  </Rule>

  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">

      <Requirements>
        <bt:Sets DefaultMinVersion="1.8">
          <bt:Set Name="Mailbox"/>
        </bt:Sets>
      </Requirements>

      <Hosts>
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <FunctionFile resid="Taskpane.Url"/>
            <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="apptComposeDemoGroup">
                  <Label resid="groupLabel" />
                  <!-- Task pane button -->
                  <Control xsi:type="Button" id="TaskpaneButton">
                    <Label resid="TaskpaneButton.Label" />
                    <Supertip>
                      <Title resid="TaskpaneButton.Label" />
                      <Description resid="TaskpaneButton.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16" />
                      <bt:Image size="32" resid="Icon.32x32" />
                      <bt:Image size="80" resid="Icon.80x80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url" />
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
            <ExtensionPoint xsi:type="AppointmentAttendeeCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="apptReadDemoGroup">
                  <Label resid="groupLabel" />
                  <!-- Task pane button -->
                  <Control xsi:type="Button" id="TaskpaneButton2">
                    <Label resid="TaskpaneButton2.Label" />
                    <Supertip>
                      <Title resid="TaskpaneButton2.Label" />
                      <Description resid="TaskpaneButton2.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16" />
                      <bt:Image size="32" resid="Icon.32x32" />
                      <bt:Image size="80" resid="Icon.80x80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url" />
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
            <ExtensionPoint xsi:type="Events">
              <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateBody" />
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
      </Hosts>
    
      <Resources>
        <bt:Images>
          <bt:Image id="Icon.16x16" DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/ckt.gif"/>
          <bt:Image id="Icon.32x32" DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/ckt-32x32.gif"/>
          <bt:Image id="Icon.80x80" DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/ckt-80x80.gif"/>
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Taskpane.Url" DefaultValue="https://ckt-d.internal.epo.org/addins/outlook/taskpane.html"/>
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="groupLabel" DefaultValue="CKT Add-in (dev)"/>
          <bt:String id="TaskpaneButton.Label" DefaultValue="CKT (dev)"/>
          <bt:String id="TaskpaneButton2.Label" DefaultValue="CKT (dev)"/>
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Sync Outllook events with CKT as Organizer (dev)"/>
          <bt:String id="TaskpaneButton2.Tooltip" DefaultValue="Sync Outllook events with CKT as Attendee (dev)"/>
        </bt:LongStrings>
      </Resources>

    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>

What am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.