Am using Outlook VSTO to create a custom button that will allow users to toggle setting e-mails as private or not. When replying to an already private e-mail the e-mail should have the private button still shown but disabled as this property cannot be changed.
Originally the logic was when the following: when opening a new e-mail set the enabled property to !IsPrivate, i.e. if replying to an already private e-mail, enabled = false, if private is not set then enable the button. The issue occurs when having a draft e-mail that was set as private, when reopening it this approach will disable the button using the aforementioned logic.
Question is how can it be determined whether the private button can be enabled or disabled using the Outlook API? The message options > Sensitivity dropdown option as part of Outlook gets enabled/disabled, how does it know when to do this? If the button's enabled property can use the same logic then it should satisfy the above requirement.
You can check whether a MailItem has been saved in the Drafts folder (i.e. not Sent) or is a new MailItem, by checking the Sent property on the MailItem.
If the Sent property is true, the message has been sent and will be read-only when opened in a Inspector window. Otherwise the MailItem will still be editable in the Inspector window.
Related
I would like to display an information message for the user when he read a specific email (i.e the email is tagged as external). The message should be displayed in the same way as outlook categories.
I know that I can use Exchange transport rule to achieve that but my client don't want to modify the message itself. He prefers displaying a message in the UI without changing the email body. The other option is to use the Office.context.mailbox.item.notificationMessages interface but as I told, I don't want to modify the email item if possible.
Do you think it is doable with outlook JS addins ?
My need is similar to this one for VSTO addin: How can my Outlook VSTO Add-in modify the read email form?
The Office.context.mailbox.item.notificationMessages interface provides the addAsync method which accepts the JSONMessage parameter which represents a JSON object that contains the notification message to be added to the item. It contains a NotificationMessageDetails object. Among properties you can find the persistent property which specifies if the message should be persistent. Only applicable when type is InformationalMessage. If true, the message remains until removed by this add-in or dismissed by the user. If false, it is removed when the user navigates to a different item. For error notifications, the message persists until the user sees it once. Specifying this parameter for an unsupported type throws an exception.
In case of categories, the message will be modified.
Do you know if it's possible to execute the function as soon as the read form is opened without having to click on an action button ?
Web add-ins are run under the context of currently selected item only. You can pin a task pane, then you'll be able to register an event handler to get notified of the change. The event handler should accept a single parameter, which is an object literal. The type property of this object will be set to Office.EventType.ItemChanged. When the event is called, the Office.context.mailbox.item object is already updated to reflect the currently selected item.
Office.initialize = function (reason) {
$(document).ready(function () {
// Set up ItemChanged event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, itemChanged);
});
};
function itemChanged(eventArgs) {
// Update on the new current item
}
Currently the event-based activation of add-in in Read mode is not supported. 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.
Currently, Event-based of activation of add-ins is only supported for Compose mode. You can explore more here- Configure your Outlook add-in for event-based activation - Office Add-ins | Microsoft Docs
Through EWS I set a category for the email and I modify the header. The category and the changed header appears in Outlook after a few minutes and sometimes you need to restart Outlook to refresh the e-mail box. How can I force a refresh for the categories and headings in Outlook?
No. Outlook caches the data displayed in the preview pane - it only sees changes made through the UI or the Outlook Object Model on the same machine.
Changes displayed in the Explorer view (message list) will be displayed immediately as soon as the data is synchronized with the server.
I am creating an addin for Outlook.
I want to check some text on sending, but im not sure how to reference it
The text is in the image below and says “Attachment will be sent using...”
If the text equals the text displayed, i want to do something.
Thanks for any advice.
The Outlook object model doesn't provide anything for reading mail tips. But you may consider using EWS for getting mail tips. See Using MailTips in EWS to get the OOF (Out of Office) Status of users with C# and Powershell for the sample code.
FYI MailTips are informative messages displayed to users in the infobar in Outlook Web App and Outlook 2010/2013/2016 when a user does any of the following while composing an e-mail message:
Add a recipient
Add an attachment
Reply or Reply all
Open a message from the Drafts folder that's already addressed to recipients
To configure MailTips for mailboxes, external contacts, and distribution groups, in the Exchange Control Panel, select the mailbox, external contact, or distribution group, click Details, and then in the MailTip section, create the MailTip.
To configure MailTips for mail users and dynamic distribution groups, in Windows PowerShell, use the MailTip parameter on the Set-MailUser and Set-DynamicDistributionGroup cmdlets.
Regardless of whether you use the Exchange Control Panel or Windows PowerShell, two things always happen when you add a MailTip to a recipient:
HTML tags are automatically added to the text. For example, if you enter the following text: This mailbox is not monitored. The MailTip automatically becomes the following: <html><body>This mailbox is not monitored.</body></html>
The text is automatically added to the MailTipTranslations property as the default value. If you modify the MailTip text, the default value is automatically updated in the MailTipTranslations property.
Read more about that in the Configure MailTips article.
In a Outlook addin I want to set PS_INTERNET_HEADERS properties on outgoing emails/meeting requests. I can see that for meetings those properties are not preserved when I open the incoming meeting (I send it to myself) - the email header for my property does not exist and I cannot see the property in OutlookSpy. for regular emails (not meetings) properties are preserved fine.
I can also reproduce this behavior with OutlookSpy - I create a new meeting, in OutlookSpy I add a PS_INTERNET_HEADERS named property, and send the meeting to myself. when I open the incoming meeting the property is gone. (it also does not appear when I open the meeting from the SentItems)
When and how do you set the properties? Keep in mind that AppointmentItem is never sent. When you call AppointmentItem.Send, a new MeetingItem object is created and sent. You can only access it in the Application.ItemSend event handler.
After dragging email item from outlook, my own application (written in C#) can get the data and retrieve the msg data when the email item is dropped on it. But is it possible to override the default "drag and drop" behavior so that I can send some information else (rather than the default information) when dragging an email item and pick up the information when the item is dropped on my own application?
No - there might be some very ugly hacks, but no usable approach.
What you could do though is utilize something from the mail in information you receive via Drag'n'Drop as a unique identifier somewhere in the mail information that gets transmitted.
With the ability to identify the mail in Outlook you could e.g. connect to Outlook via automation or use a minimal Outlook AddIn that can be queried for what you need.