I have a need to add tasks that I programmatically create into a folder within Outlook.
I have code that creates a task and I also have code that creates a folder. This works fine.
Now the tricky part, how can I add my newly created task (the task is an object in memory at this point) to my newly created folder (Or just a folder in general)?
At this point I am looking to just add them to a folder, however in Outlook I am able to create a 'folder' like item that I can create tasks in (see attached screenshot). I would love to really be able to do this programmatically instead of a folder.
Does anyone have examples or documentation that could possible point me in the right direction?
If you have a reference to a Folder, you can use Folder.Items.Add to create a TaskItem in that Folder.
If you used Application.CreateItem, then you should use TaskItem.Move to move the item into a specific Folder.
Related
So in my application I have created, there is a button that will create a folder in a user-selected location, I want to add another button to my application that when clicked, will pull up this folder that has just been created.
I have looked into using Process.Start($#"C:\Users}); but have no way of using the folder path as it has not been created before starting the application. How would I get around this?
You can do it like this.
Process.Start("explorer.exe", #"Path of the folder that you want to open");
Just make sure the user by which you are running the application must have access to the folder. Otherwise, you might get issues related to access control.
In Outlook, I'm trying to add a shared public folder (provided by Exchange) to the list of favorite folders programmatically.
I've written an Outlook-AddIn for this, that uses the Microsoft.Office.Interop.Outlook library. In this library, there's only one way to add public folders to the favorite list:
Folder.AddToPFFavorites().
The problem: When calling this method, Outlook not only adds the folder itself to the favorites list, but also ALL subfolders. In our company, we have a huge tree of subfolders attached to some folders, so I get major performance problems (Outlook completely crashes when the folder to add has too many subfolders).
Do you know a way to programmatically add only the folder itself to the favorites, without any subfolders?
The Outlook object model doesn't provide anything for that. You have to use the AddToPFFavorites method of the Folder class.
I want to replicate all changes to a given folder. I use the FileSystemWatcher in C# and I can detect most changes. One type of change that I cannot detect easily is a move of a complete folder to the watched folder. I receive only a create-event for the folder but no events for the content of that moved folder. I can think of some logic to figure out if it is a move or just a creation of a new folder, but it seems awkward that it is quite hard to do this. Any suggestions in easy/out-of-the-box folder-move detection?
Thans a lot!
I receive only a create-event for the folder but no events for the content of that moved folder.
That's correct as OS does not "copy+delete" the folder internals. It's just "relink" the folder in the file system. As just a 'fast' idea - you cold check if 'created' folder is empty or not at the moment the create event received. If the folder is not empty you cold assume it was moved.
In my C# code I want to be able to use some Shadow Copy mechanism in order to copy files that are being used by another process.
I've seen that solutions exist on the web, in enterprise or command line tools. But could it be done programmatically in order to mimic a simple file copy?
It appears that alphavss does what you want. The sample file VssBackup.cs here seems to do exactly what you want.
This class encapsulates some simple VSS logic. Its goal is to allow a user to backup a single file from a shadow copy (presumably because that file is otherwise unavailable on its home volume).
I'm trying to develop an AddIn - or rather, just a proof-of-concept for now, to see if what I have in mind is actually even possible - for Outlook (2010, to be exact), in .NET/C# and I'm facing the following problem:
The AddIn is supposed to offer a new custom Folder (on the top level of the hierarchy, i.e. next to all the other main items, like Tasks, Calendar, Contacts, etc.) in which to offer items to the user. So I figured that in the Startup method of the AddIn I could simply do something like
Outlook.Folder parent = inBox.Parent as Outlook.Folder;
Outlook.Folder myCustomFolder = (Outlook.Folder)parent.Folders.Add("My Custom Folder");
... and that does in fact work. However, there's a problem after quitting Outlook and starting it again. Since the folder is being persisted by Outlook, it is still there the next time Outlook launches and initializes the AddIn again, so the creation of the folder fails because an object of the same name already exists. But I don't see any way how to tell that this is "my" folder from last time.
I don't want to rely on its name to identify the folder (that's just too unreliable to even consider; users might want to rename it, other AddIns might exist that create a folder of the same name, not to mention localization problems etc.), but what else can I use to determine that the custom folder has already been created?
I would either have to be able to somehow add a "tag" do the folder so I can later recognize it as "mine" - or alternatively would need some kind of id that uniquely identifies the folder (and which remains constant even between launches of Outlook!) so I can recognize it by that.
I have been looking at the EntryID and StoreID fields of the [MAPI]Folder object, but from the (sadly, not very detailed) description at the MSDN, I'm not sure if I can rely on them, because apparently they can change under certain conditions.
Any suggestions?
Unless the folder is deleted and then recreated, the entry won't change. But it won't be the same folder anyway - just another folder that might have the same name.
What Outlook does is store the special folders' entryids on the root IPM folder and/or the Inbox folder.
Since you cannot set named properties on folder in Exchange and you cannot just pick your own property tag without risking running into a conflict, create a hidden message in the Inbox folder(which is always present in the default store) and store the folder entry id along with whatever else configuration properties you might need. To make sure your config hidden message is unique, pick a unique mesage class, e.g. IPM.Note.MyCompany.MyAdddin.Config.
Hidden messages can be accessed using MAPIFolder.GetStorage in the Outlook Object Model or RDOFolder.HiddenItems in Redemption.