On-send add-in not loading after Outlook error - outlook

I am developing an Outlook 'on-send' add-in which loads a dialog box if the email is addressed to multiple recipients after the send button is pressed. In the dialog, the user confirms the intended recipients from a list and then presses send. The add-in then allows the send event to happen.
A problem arises if the emails are not formatted correctly; Outlook throws a ‘does not recognise email’ error after trying to send the email. The problem is that when I try to send the email again after the error, the add-in does not load. The add-in should load every time the user tries to send an email to multiple recipients.
Please see a video of this behaviour here: https://youtu.be/U1VFuy1qbHM
As you can see from the video, the email goes to my Outbox fine after the first send. However, Outlook throws an errors when I edit the email in my Outbox and try to send it again (presumably because I was using a made up email to test with). As you can see, if I then update the emails and click send, the email sends without the add-in loading again. The intended functionality of the add-in is that another dialog box should be displayed in this case.
This behaviour also occurs when you reply to an email where the recipient has their email address formatted differently. For example, 'Name Surname (name.surname#domain.com)' instead of 'Name Surname <name.surname#domain.com>'. Outlook does not seem to like this format and throws a similar error after trying to send the email. After updating the email format and clicking send, the add-in does not load again.
The error occurs in Win32.
I do not think the problem is with the Javascript. I think the add-in does not even load when I try to resend the email. Maybe the add-in is somehow holding onto the ‘True’ value of the on-send event from the previous dialog box? I have tried editing the different ‘ReadorEdit’ values in the Manifest file to try and ensure the add-in loads for all cases but it has not helped.
What can I do to ensure the add-in loads after these errors?
Thank you for your help- it is very much appreciated.

Related

Outlook API, Message Moved to "Sent Items" still beign marked as "[Draft]"

I'm working on an Outlook Add-in, using office.js, where users can send secure emails using backend service.
In compose mode, when the user sends the email, using the add-in of course, the add-in will then move the message to "Sent Items" folder using the Outlook API /message/{id}/move and everything goes OK with the exception that the message in question still being marked as "Draft" by Outlook which is really annoying and does confuse the user who just sent the email by telling him that "this message hasn't been sent"
I searched through the API to see if there is a way to mark an email as "SENT" in order to prevent Outlook from showing this RED hint but with no luck so far!
So, My Question Is: Is there any way to overcome this misleading msg by marking the email as it was sent by Outlook?
Thanks in advance.
Finally, I was able to achieve a perfect solution for this challenge.
Based on:
#BrianClink's comment
This answer (Which uses Graph API but Outlook REST API): Microsoft Graph API mail office 365: Is any option create inbox message NOT as Draft?
The approach/steps I followed to mark a mailItem as "SENT" (and not shown as 'draft') and put it in "SentItems" Folder are as follow:
First, Save the mailItem as "draft" using Office.context.mailbox.item.currentMail.saveAsync then retrieve its ID
Clone this draft mailItem properties eg: 'Sender', 'Subject', 'Body', 'ToRecipients'..etc so you get an exact copy of it.
With the newly cloned mailItem, add '[SingleValueExtendedProperties]' property with this value :
[
{
PropertyId: 'Integer 0x0E07',
Value: '1'
}
];
Serialize the new item as JSON and POST it to "sentitems" folder as follows:
xhr.open('POST', restHost + '/v2.0/me/MailFolders/sentitems/messages/');
xhr.send(clonedEmailJson);
On success, with xhr.status=201 [created], Remove the draft mailitem using a [DELETE] request
And you will end up having a new mail item created in your "sentItems" folder which appears as it was sent by Outlook :)
This was a very helpful solution to me because my users are using my add-in to send secure emails (using 3rd party API) and NOT Outlook, So, I wanted them to have the same UX/feeling as when they use Outlook.
Note:
Although the solution worked for me perfectly, it came with a price!
On slow internet connections or in case emails containing large attachments, the process can be remarkably slow, because the addin will first save the draft to the remote Exchange Server, get its ID, then duplicate it and send it again to the server, then remove the draft-ed one.

Outlook Message webLink with ispopout=0 working only with Inbox

I'm currently building an integration with Office 365 Outlook thanks to the Microsoft Graph API. I retrieve user messages data, along with the webLink, which is a direct URL to the message in Outlook Web App.
By default, it opens in a popout window displaying only this message. My goal is to display it in the full Outlook Web App. In the documentation of a Message resource, Microsoft states this:
You can append an ispopout argument to the end of the URL to change how the message is displayed. If ispopout is not present or if it is set to 1, then the message is shown in a popout window. If ispopout is set to 0, then the browser will show the message in the Outlook Web App review pane.
Doing this works well if the e-mail is in the Inbox mail folder. However, if it is in another folder (like Sent Items or a custom one), it always redirects to the Inbox and opens the first message in it.
Is it a known limitation of this parameter? Is there a workaround to achieve this?
Best regards!

Create text/calendar type email that triggers accept/reject/ignore options

I can programmatically create an email with an .ics file attached. The email gets sent, the recipient clicks the .ics attachment to add it to their calendar. This is easily done.
I want to try and make Outlook behave a little different. When the user previews the message it detects that its calendar type and throws a prompt asking the user to take some action. This action decides if it gets pushed into the calendar. In a perfect world to have accept/reject/ignore options would be super sweet. Is it possible to construct/send and email in such a way that Outlook can treat it different from a standard email? E.G perhaps altering the type (CONTENT-TYPE:text/calendar)?
Note - I have seen a solution where the body contains a link to the .ics file informing the user about the calendar invite details. It then has a click here to Accept. This is nice because the .ics file does not have to be attached.
I am workign in VBScript/VBS world although Im not sure this is all that important. Has anybody done this is any sense. Is it even possible?
edited:
I ended up using the EASendMail component located here it has an autoCalendar property which works really well. It embeds the .ics file as a text/calendar and send the message as a text/calendar. The outcome is perfect, just like it was actually sent from the outlook. It previews with with the action buttons and even loads the meeting in Outlook at tentative waiting for action
Your email needs to follow a proper MIME structure for it to be recognized as an invitation. See Multipart email with text and calendar: Outlook doesn't recognize ics

MS Outlook - Send messages located in Outbox

In my MS Outlook 2007, I have multiple (several hundred) messages in the Outbox and they are marked in bold, but NOT marked in italics. Hence, I cannot send them unless I open each message individually and hit the Send button :(
Is it possible to use a VBScript to send these messages?
I have no knowledge in scripting whatsoever.
Thank you for your help!
I have multiple (several hundred) messages in the Outbox
Did you submit these messages manually and they are stuck in the Outboox?
Anyway, you can automate Outlook from VBA. See Getting Started with VBA in Outlook 2010 to get started quickly.
Pay special attention to the ItemSend event of the Application class. It is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program. You can display a custom dialog for confirming. The Cancel parameter passed to the event handler allows to cancel the action. If the event procedure sets this argument to true, the send action is not completed.

Delay emails sent and received through IMAP

I want to put emails the user receives in a sort of "review status" in my app and let users choose manually if they want them to be let through.
For this I need to filter network traffic to withhold emails receivef with the IMAP protocol from Outlook and send them some time afterward. And to the same for emails being sent.
Would this be possible to do on Outlook on Windows 7/8? Or would I be unable to make Outlook receive the mailing after I filter it out?
The Outlook object model doesn't provide anything for foltering emails.
Instead, you may consider handling the new email programmatically in the code handling the NewMailEx event which is fired when a new item is received in the Inbox. For example, you may develop a VBA macro for doing any customizations in Outlook programmatically. See Getting Started with VBA in Outlook 2010 for more information.

Resources