I am doing changes on an Outlook.MailItem but after closing the last explorer a message box asks to save the item (twice!).
I want to cancel the "dirty" state of the item without saving it so no message box will be displayed.
Is it possible to accomplish it? The only solution that I have is persisting the previous state and saving it again.
You need to release COM objects, created in your code. See When to release COM objects in Office add-ins developed in .NET.
Related
I have an Outlook Add-in in which I need to subscribe to ItemAdd event for all the folders in the heriarchy in order to monitor and do some stuff. After subscribing to it I have observed that the default Outlook behavior for folders on ItemAdd is missed, for example, in particular the draft folder, I mean, I write a new email from compose window and then I do not send it, I simply close compose window so Outlook asks me if I want to save changes and I click on yes button but the problem is that the email saved into the draft folder does not show the date, date of the draft appears as "None". So what am i doing wrong?
An empty ItemAdd event handler is not related to the issue. Only your could cause issues. To give a more precise answer you need to publish your code.
I am trying to modify a Mailitem's category. First, I set
mail.Categories = "";
mail.Save();
Then at some later point, I set the following:
mail.Categories = "Red Category";
mail.Save();
This works most of the time, but sometimes the old category is stale in the messages pane, while the category displayed in the message is correct. If I right-click, only the Red Category is applied as it should. Is there a reason I am experiencing this inconsistency?
Sometimes you need to refresh the view in Outlook by switching to another folder or re-opening an inspector window if you make changes through the Outlook object model.
For explorer windows you may set the CurrentFolder which allows to set a Folder object that represents the current folder displayed in the explorer.
For inspector windows you may close it, release the item shown in the inspector window and then re-open an item by using the EntryID value. See the NameSpace.GetItemFromID method which returns a Microsoft Outlook item identified by the specified entry ID (if valid). Sometimes just re-opening an inspector window helps.
In office applications i want to get the word on which the user right clicks.
i was able to get for Excel and Word. in outlook and PowerPoint i am not able detect the right click event.
In outlook i want to detect right click on a word in mail body.
In power point i want to detect right click in a slide content.
In outlook i have tried the events:
ItemContextMenuDisplay,
AttachmentContextMenuDisplay,
FolderContextMenuDisplay,
ContextMenuClose,
StoreContextMenuDisplay,
ViewContextMenuDisplay,
In power point i have tried:
WindowBeforeRightClick,
can somebody help me with the events to be used?
I will try to answer the Outlook part.
The Outlook object model doesn't provide any events for that. The only possible solution is to add your control to the context menu and handle the getVisible or getEnabled callbacks. Thus, you will be aware when the context menu is going to be displayed. But it seems MS doesn't provide the required IDs for that menu, see Extending the User Interface in Outlook 2010 for more information.
See Office 2013 Help Files: Office Fluent User Interface Control Identifiers
In the case of PowerPoint, WindowBeforeRightClick is the correct event.
You would find that setting Cancel = True in the handler for that event only works if the right-click is on the slide itself. On a shape or within a text range this fails to work as expected.
Workaround is the lock the screen and switch to a different view and back and then update the screen to prevent the contextual menu from appearing for the shape/text range.
I'm trying to programmatically intercept and cancel a user's attempt to check out a file in TFS.
Am I correct in thinking that the proper way to go about this would be to handle the NewPendingChange in a Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer ?
What is the proper way for canceling the event from its event handler?
I was wrong! TFS does allow me to disable merge and multiple check outs on sln/csproj files!
In the "Team Foundation Server Settings > Source Control File Types..." dialog I was able to add new file types (one for sln and one for csproj) and set the File Merging attribute on them to "Disabled". Works like a charm.
Too bad I still don't know how to answer my original question - how to cancel a NewPendingChange event.
I've created an empty Outlook 2007 Plugin Project in Visual Studio 2008 (SP1). Then I added a new Form Region (Contact type, Adjoined, otherwise defaults) and then I run the project.
Outlook opens, I go to a contact change a couple of things, then click on the close button. Outlook asks if I want to save, I choose No.
My understanding is that this should reset all changes I made. But if I re-open that same contact all my changes are still there. If I close the whole outlook it will re-prompt me to save the contact I changed.
This leads me to thinking that the default Form Region template actually keeps a reference to the Contact it is being shown for and not disposing of it after the form region is closed. This causes the contact to be in memory and not simply disposed after closing the form.
Can anyone reproduce, or is it a feature? Any way to get around this?