I would like to see if there is any way that anyone replies in a shared mailbox to any email and the email is automatically flagged in outlook. Can be via Power Automate or VBA.
One way or another, you would need to set the MailItem.Categories property and/or MailItem.ReminderSet / ReminderTime properties on the original item in the folder.
You can use Explorer.SelectionChange event to track the item selection, set up MailItem.Reply/ReplyAll event handlers on the item(s) from the Explorer.Selection collection, and then set the reminder properties in the event handler. Or you can use Explorer.InlineResponse event to set up the properties on the first item in the Explorer.Selection collection
Related
I have an Outlook VSTO add-in. I want to respond to incoming emails. This works quite well with the declaration
Public WithEvents items As Outlook.Items
And the definition for the items that are observed. (I'm afraid that's why only "Inbox" is watched):
inbox = objOutlook.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
items = inbox.Items
and the eventhandler
Private Sub Items_ItemAdd(ByVal item As Object) Handles items.ItemAdd
Even if Outlook is closed, an event is triggered for each new email when Outlook is started.
I've now noticed that some users of the add-in have created a rule that moves incoming emails to a subfolder of "Inbox". In this case, the Items_ItemAdd event is not fired when a new email arrives.
How can I also capture these new emails that are moved via a rule?
The item is moved on the server side by the server side rule, and even if Outlook was running, it could've been moved before Outlook downloaded the original item to the OST store. So if ItemAdd event fires, it only fires on the folder where the item was moved to, not in the Inbox folder.
Besides watching the Inbox folder, you'd need to watch the other folders that the rules might point to - retrieve the rules using Store.GetRules(), loop through all rules, check if Rule.MoveToFolder action is enabled, and if yes, retrieve the target folder from MoveOrCopyRuleAction.Folder property.
Use the NewMailEx event of the Application class which is fired once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.
Also you may track the items in the folders by combining multiple mechanisms like this event handler plus getting new items at startup to not skip any of them that was added silently. The Find/FindNext or Restrict methods of the Items class can help you with such tasks. Read more about that in the series of articles:
Outlook NewMail event unleashed: the challenge (NewMail, NewMailEx, ItemAdd)
Outlook NewMail event: solution options
Outlook NewMail event and Extended MAPI: C# example
Outlook NewMail unleashed: writing a working solution (C# example)
is there any chance to make the following scenario working
user gets email in Outlook containing link/text/object
clicking the object runs simple VBA code (i.e. replace string in txt) file on users computer
Thank you.
No, it is not possible. This is a potential path for malware.
Instead, you can handle the NewMailEx event of the Application class in Outlook VBA macros where can detect such mails (with a specific text or links) and run your business logic accordingly.
The NewMailEx event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.
I try to prohibit in certain cases that the user deletes an appointment. Something like this:
User clicks on appointment in calendar
User selects delete
VSTO-Addin checks whether this is allowed and shows a warning dialog in case if not. Outlook does NOT delete the appointment!
Currently I attached to Item_Delete_Add() and I think that one can only handle the deletion but you cannot prevent outlook from actually deleting the appointment. Correct?
You are on the right avenue... The Items.ItemRemove event is fired when an item is deleted from the specified collection. This event does not run when the last item in a Personal Folders file (.pst) is deleted, or if 16 or more items are deleted at once from a PST file, Microsoft Exchange mailbox, or an Exchange public folder. Moreover, you must keep the reference to the source object to know which item is being deleted from a folder. To get this working you must subscribe to the SelectionChange event of the Explorer class. It is fired when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface. So, you could subscribe to every selected item and know which item exactly is removed.
Another possible way is to handle the AppointmentItem.BeforeDelete event which is fired before an item (which is an instance of the parent object) is deleted. An instance of the item being deleted is passed as a parameter. In order for this event to fire when an email message, distribution list, journal entry, task, contact, or post are deleted through an action, an inspector must be open. The event occurs each time an item is deleted. It also allows to cancel the actions by setting the second parameter - if the event procedure sets this argument to true, the operation is not completed and the item is not deleted.
Yet another approach is to repurpose ribbon controls, see Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.
Before sending the appointmentItem in outlook 2010 I have created an extended property and set some values. The property is not available for the recipient (recipients are using outlook and they are from the same domain).
However, the property is available in the owner's calendar item.
Any inputs about this issue is much appreciated.
Keep in mind that ApointmentItem object is never sent - Outlook creates a MeetingItem object and sends. The original ApointmentItem remains in the Calendar folder.
You can try to use Application.ItemSend event - Outlook will pass MeetingItem as the parameter, and you should be able to set the extra properties. Now where these properties will be copied by Outlook from MeetingItem in the Inbox to the new ApointmentItem is a different question...
I have already replied to your post on MSDN forums two days ago:
The fact is that a meeting item is not sent to a recipient. Instead, a corresponding meeting request is created and sent to the recipient. Just check the message class of the item when the item is sent. You can handle the ItemSend event of the Application class which 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.
I'm developing an Outlook Add-in, and currently I have no idea on how to capture the task's checkbox (mark complete) tick event -- particularly on the 'Outlook Today' view. I'd like to override it with my own function.
Refer to the attached image as reference to the checkbox being referred to.
Outlook Today Task
The Outlook Today page is not a typical area that can be integrated with. It is possible though, as it is basically an .html page; see: https://technet.microsoft.com/library/cc750169.aspx. However, this is 20 year-old technology...
If you are mainly interested in trapping changes to that task, then you can trap the Items.ItemAdd event for the Tasks folder and do whatever you like with the modified Task.
The Outlook object model doesn't provide anything for the Outlook Today page. It just lists items from your folders. So, you may consider handling the following events to get the job done:
The ItemChange event of the Items class which is fired when an item in the specified collection is changed.
The PropertyChange event of Outlook items which is fired when an explicit built-in property of an object is changed.
Both events are fired when you mark the task as completed. But in case of the PropertyChange event you need to subscribe to each task item individually which is not really convenient.