how to display some message once user starts to compose new email - outlook-addin

For Office 365 Outlook Web App, we would like to convert attachments to links once end user uploads them, however we didn't see an attachment notification event at current Outlook Addin.
Another approach we could do is to ask them to use our own buttons for uploading, however we need to guide end user to use our own buttons, could we add some message at top of email body like below once new email message box is displayed?
Somehow based on our research, Outlook Addin only has one event right now which is SendEvent, could someone confirm this? if so, it is rather limited.

To display a custom message use Office.context.mailbox.item.notificationMessages object. For example to add a message to current item the code may looks like ...
Office.context.mailbox.item.notificationMessages.addAsync("information", {
type: "informationalMessage",
message : "My custom message.",
icon : "iconid",
persistent: false
});
Be aware there are a maximum of 5 notifications per message and maximum length of each message text is 150 characters per Office.NotificationMessageDetails interface.
For the secondary question you would need to look at available events in Office.EventType enum. Over here you'll see few events available to Outlook app. One of them you are interested in is AttachmentsChanged which is currently available only in Preview (not released yet, but will be soon).

Related

Outlook Forms: Recipient does not receive form, only message body //How to store form's data in an email?

I am currently trying to create a form in Outlook. I want to be able to send this form to different people so that they can make changes to the form and send those changes back to me as a response.
I have a published form in the meantime. My current problem: The recipient does not see the form until he "undocks" the email from the Outlook app and the changes made there are not transmitted to me; I just get an empty form. How or where can I save this data that the recipients enter? I am grateful for any help!
The form definition includes all the fields and the code that you add to the form. As a general rule, publish the form definition to a forms library instead of sending the form definition with the item. If you cannot publish your form to a forms library, you can select the Send form definition with item check box on the Properties page so that other users can see the form pages when they receive items that are composed by using the form.
Forms that you only intend to use once and not publish are referred to as one-off forms. Because of security concerns with one-off forms, users might not see the form correctly when they open items sent to them with a one-off form. In this case, sending the form definition with the one-off form provides the necessary information required to display the form correctly for the users.
To change how users reply to your form, click the Actions page. The Actions page lists the default Reply forms that are available. You can also add your own custom Reply forms. For example, forms based on a new email message have built-in Reply, Reply to All, Forward, and Reply to Folder forms. When users receive your form, the form contains buttons and menu commands so that users can respond to the form. You can disable some or all of these default forms and set attributes that define how these Reply forms appear.
Read more about that in the Create an Outlook Form section of MSDN.

Outlook VBA - Create an email, allow the user to send, then execute further code

I have an outlook Macro that collects some information from existing emails and a local database, then serves up a templated email with the information. The user can then review the email, make changes if they want to and then send or not sent (quit/cancel). Is there a way, I can keep the macro running and then execute more code if the user sends the email?
I've created some psuedo code below on how I'm hoping it might work:
Function CreateEmailThenExecuteCode()
Dim newEmail As MailItem
Set newEmail = Application.CreateItem(olMailItem)
newEmail.Display
'Allow user to review and send email
'If they 'send', then execute further code.
If Not Sent Then Exit Function
'Further code
End Function
I know that I can create a new macro that runs every time a user sends an email - but it would be much easier if I can keep the existing macro running, as otherwise I need a way of saving the data from the running macro.
I also know that I can create a custom user form that mimics an email user form - but I would prefer to keep the functionality of the full email user form, especially with access to email address lists etc.
Is it possible?
The Display method doesn't prevent your code from running until you pass true to make the Inspector window modal. The default value is false.
At the same keeping the code running after the Display call doesn't allow users to deal with Outlook UI because the VBA code will be run on the main thread (UI).
You may consider setting up an event handler for the Send event which is fired when the user selects the Send action for an item, or when the Send method is called for the item. So, you will be aware when the item is sent out.
Also you may find the MailItem.Close event helpful. It is fired when the inspector associated with an item is being closed. So, you will also be aware when the item is closed.

Custom appointment form is different when opening appointment

I have made a custom form region for my appointments in outlook - Which I really would like to use.
However, I have a problem with implementing it in my outlook.
When I want to schedule a new appointment, it opens up the correct form that I want to use - and works without any issues.
However, the problem occurs when I want to open and see my appointment. Here, it shows some previous published version - Which of cause does not properly work.
Things I have tried
I don't remember, that I at any time specified a default form to use upon opening an appointment. But the way it acts, it seems like I did.
I have tried deleting and republish my form with a different name
I have tried specifying "When posting to this folder, use" for my calendar
Still, it keeps opening already scheduled appointments with a completely different form, that I made several days ago.
Every Outlook item has the class name set, so that is how Outlook knows which form should be used to display the item. See Associate a form region with an Outlook message class for more information.
Also, you may take a look at the Assign a custom form to existing Outlook items article.

Outlook plugin - Fetch emails with specific message ids

I am writing a plugin for Outlook, where I need to fetch only few emails based on some back end Logic.
I have stored those email Message Unique Ids in my DB. And on click of plugin Icon, I wish to load only those Emails to load in my Inbox.
Example, the logic is same as how we click on particular folder like sent items or unread items, it refreshes the Inbox with only the respective emails.
I have created a plugin icon following the tutorial:
https://learn.microsoft.com/en-us/outlook/add-ins/addin-tutorial
Using NodeJS for coding. Can you please give a pointer, how do we load emails in Inbox? or if we can load only specific emails in Inbox?
This is not possible if you're attempting to use the Outlook's inbox display module to show the items you're refreshing. You will have to open a dialog / or a new browser tab to show the custom list of items - which I think is not good user experience. As Brian called out, office-js add-ins are quite restricted.

Is there an event when user types a subject?

I want to autofill a subject based on what the user types in to the subject field of an email. For example, the user starts typing T201234567 and the program will fill in the rest.
T201234567 SR9&54 Project title
I found the event for when a new email is created, but I would ideally like to have this program be as unobtrusive as possible, so it would only suggest titles, as the user is typing in something it recognizes.
So, is there an onKeyPress event for the subject field?
No, there is no such event. PropertyChange ("Subject") event will fire only when the user tabs out of the Subject edit box.
You can find the control's handle using Win API and intercept its Windows messages, but you cannot do that in VBA.