C# parse outlook calendar item - c#

I am writing an application that employees in our business use to capture their timesheets. My colleague that helps with the development got a brilliant idea to add a feature that an employee can drag and drop their calendar entries from Microsoft Outlook and a timesheet entry will be created with the correct details.
It was easy to create the drag and drop feature but only the meeting title and location get exposed. The interpretation code is this:
Object item = (object)e.Data.GetData(typeof(System.String));
textBox1.Text = item.ToString();
The result I get is this:
Time Sheet parameters and data capturing strategy (East Meeting Room 3)
I have tested it by dragging it into Microsoft Word and then there just appears an Outlook item on which you can double click to open the event.
Is there some way I can access the meeting's start and end time in my application?
Edit: I have tested Office Interop libraries and it works like a charm, though I would like to avoid the use of that. People in our office have different versions of Microsoft Office and I could not be sure that it would work on every PC.

Related

How can I change colours in Outlook via VSTO?

Good Morning,
Since a few days, I'm searching for an opportunity to change colours in Outlook by VSTO (Visual Studio Tools for Office - C#).
I would like to change the colour of the recipient, which I write down when I would like to send an e-mail.
Is that even possible?
I don't find anything on the web about that, but it would be the best solution for my project.
The Outlook extensibility model doesn't provide anything for customizing the Outlook UI, i.e. changing colors of the recipients.
The best what you could do is to use the ContactItem.Categories property which allows setting a string representing the categories assigned to the Outlook item.
Categories is a delimited string of category names that have been assigned to an Outlook item. This property uses the character specified in the value name, sList, under HKEY_CURRENT_USER\Control Panel\International in the Windows registry, as the delimiter for multiple categories.

Outlook VSTO Addin

I'm currently working on add in to outlook but face a problem my requirement is to add feature that is similar to spell checking (program will underline some of the text in real time). Is that even possible in vsto ? any material is appreciated i've searched for answer online - without any success
The integration you need would not be with VSTO or the Outlook Object Model, but rather mainly with the Word Object Model (WOM). Outlook users Word to render HTML formatted messages and provides access to the email as if it is a Word document, via the Inspector.WordEditor property which returns a Word.Document object.
So you can use WOM to format the body content as you see fit. However, there are no real-time events for hooking into changes of the message body as they occur. You will need to use either timers or low-level keyboard hooks to capture the changes that the user is making.

c# new mail from outlook with attachment

This has been asked before in one way or another, but i need some clarity on an issue I am having.
essentially, my client wants his app (wpf, written in VS2010) to be able to create new messages in his outlook (not send them, but just popup with the new mail message with certain fields filled in - he will type up the rest of the body and then send)
So to date I have just been going the route of using the mailto:
System.Diagnostics.Process.Start(string.Concat(#"mailto:" , toAddress , "?subject=" , subject));
easy peasy.
Now he wants attachments to be included. Doing some reasearch I see that there once was an &Attach tag I could add, but it doesn't work for me. further research revealed that its been killed off since office 2007 (I have 2013 installed on my box, client has all different types) so I cant use this method.
Further reasearch suggests that i go the COM automation route. there are nice tuts online like this one on MSDN
seems simple enough but I get stuck at this point
Step1. Create a Console application and reference the Outlook Primary Interop Assembly (PIA). To reference the Outlook PIA, right-click the project file and click the "Add Reference..." button. In the Add Reference dialog, navigate to the .NET tab, find Microsoft.Office.Interop.Outlook 12.0.0.0 and click OK.
Now I have a bunch of different ones (v11 - v15)
I guess because of different versions of office I have had.
Now my question is
Which version should I pick
What happens when I publish (clickonce) and deploy to my client given that their machines all have different versions of office.
Will the highest version accommodate them all?
Can I pick one to suite them all
(note: It has to happen through outlook so i cant use the normal .net mail method - that would have been great if i could)
Thanks
My recommendation is not to use PIAs, use NetOffice instead, as it provides a very nice abstraction and will work with any Office version (https://netoffice.codeplex.com/). Will also work nice with Clickonce distribution.

Creating Outlook Email Draft via C# Application

I am in the estimating phase of a project, and one requirement is that my application will create draft emails (with attachments) in MS-Outlook, which the user can then review and send. The app is written in WPF.
The clients will have either Outlook 2003 or Outlook 2007. The files that need to be attached will already exist on the file system when the drafts are generated.
I have done some initial research, but would like to get some opinions from people who have first-hand experience.
Questions:
What tool would you use to
accomplish this?
Will there need to be separate code for Outlook 2003 vs. 2007?
In general, using whatever tools are recommended, is this a relatively straightforward problem to solve?
Thanks for any insight.
a c# wpf application should be able to do the job just fine, you just need to add the outlook libraries in your references and you can work with outlook directly from your WPF app.
I only write for 2003, but I do know that 2003 and 2007 use different libraries. There's probably a clever way check what version of outlook is being and use the methods from the correct library, but it will take some work to figure out.
It's relatively straight forward except for the security prompt you'll get if you send the email. But I suppose if they are going to have them review it first, you should be able to generate the email, open it in an outlook window for them to review, and have them click the send button.
Would you be able to use WebDAV and then simply create the message and drop it in the users' Drafts folder?
Basically, you'll end up using something like this product (or you can roll your own) to create and save the message. You might be able to find an open source solution.
I think there are a couple tools you could use here:
Visual Studio Tools for Office (VSTO)
total control over Outlook
version of Outlook may matter
Assuming you have Exchange, you could use WebDAV, Exchange's XML methodology
version of Outlook wouldn't matter here
Use the built in mailto: functionality
lots of results for using this to include attachments - Google Results
would work for email apps other than Outlook
this probably would be quickest solution, but the least control over the output
An Outlook Add-in is probably a good way to go for this application. The tool set you need is Visual Studio Tools for Office (VSTO). With the possible exception of the WPF requirement, this is pretty straightforward.
Be aware that the API's and the VSTO tools evolved between 2003 and 2007. You can potentially have a single code base but you will need to write for the least common denominator, 2003.
2003 and 2007 also have different Primary Interop Assemblies, the components that bridge the gap between your .NET code and the native code COM interfaces that Outlook has. This can be a challenge when it comes to building and installer for your add-in. If you want your add-in to install the PIA's, you need to detect the version of Office and install the appropriate version, or, more commonly, just build two different installers.
I've never tried to do WPF inside Outlook 2003. There may be some issues with it but I don't know.

PowerPoint record slide show function accessible through Interop with C#

I am currently trying to write an addin for PowerPoint that whenever any PowerPoint document is opened and then run in show mode that the feature to record narration audio and slide timings is automatically activated.
However I cannot seem to find that option in the PowerPoint interop object
The manual in application way to use this feature in Powerpoint 2007 is under the "Slide Show" tab of the ribbon called "Record Narration".
I have found under that I can set under Microsoft.Office.Interop.PowerPoint.SlideShowSettings.AdvancedSettings to RehearseNewTimings but this does not record narration audio.
Does anyone know if this is even possible? Or if I am completely on the wrong track here.
Thanks in advance for any repsonse
Can you record a macro of this record operation to do the same thing?
As I discuss on my blog entitled, Tribal Knowledge: Working with Office Interops, one way to divine the inner workings of any office document and how to manage it via the interops is to record a macro of the process needed. Once done examine the vba code, it will show settings changes and other items of interest that can lead the way through the tribal knowledge of the interops. Most the object calls are the same under the covers...good luck.Otherwise if try this question in the forums of Discussions in Office Development or Discussions in Automation which is a good one for interop questions.HTH

Categories