c# new mail from outlook with attachment - c#

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.

Related

WebDav Word 2016 Checkin Button

I just saw in a video about sharepoint (https://www.youtube.com/watch?v=jhVWtlItL6k Minute 6:50) that in sharepoint there is a Check In Button. Now my question is is this also possible with ItHit WebDav too? Or is this a button from the Sharepoint Plugin and can only be rebuild with an own plugin?
The Video is from Office 2013, I have Office 2016 maybe thats why the Button is not there.
Otherwise the CheckIn can also be done by closing and saving. But preferably I would like to have an option to Make a Checkin and Signal my Application it should make the Safe a New Version (Optionally with a description input).
Also I saw there is the property AllowOffice12Versioning (which said here was experimental:
Show Versions within the document (IT Hit WebDav) )
The Versioning Support for DeltaV cannot be reused for word right?
https://www.webdavsystem.com/server/documentation/creating_deltav/
Is there any progress on it since 2014 or how is this acutally realized in Office? Does it use any of the WebDav Extenions by Microsoft which I could extend myself if no progres yet? (MS-WDVSE, MS-WDVME, MS-WDV, MS_WDVME...)
Unfortunately, unlike other operations, versioning in MS Office is not using WebDAV, as this post describes: Show Versions within the document (IT Hit WebDav). MS Office is using its own proprietary protocol to display versions.
One possible solution is implementing check-in/check-out commands and versions list in the IT Hit WebDAVDrive sample based on IT Hit Virtual File System product. This sample works similar to OneDrive (it using the same Windows API) and can automatically lock/unlock documents on the virtual drive, which is very close to check-out/check-in. You potentially can add check-out/check-in/list versions commands to the Windows File Manager context menu as well as attach a hook to file open/close or lock/unlock events in sample code to show a custom user interface.

How to add plugin for Excel Online?

I would like to use Excel functionality from a browser. I currently have an excel based Microsoft office application. It adds an icon to the ribbon and does C# based custom application logic to communicate to a database server.
Since it requires application releases for any changes in the schema I am curious if I can convert this into an web application and still benefit from Excel's built in functionality.
I am expecting this to be possible since Microsoft Excel Online is run inside a browser. My question is, is it possible to add plugin to such online excel document? If yes, any example would be much appreciated.
You absolutely can, and depending on approach you can do so with nothing more than a VSTO project template. This is little more than a ClickOnce application. This can launch a browser within a window to perform the logic.
You may use the Office Interop assemblies to decouple your application from Office apps, yet still communicate easily. Make sure you set Embed Interop Assemblies to true once added as a reference.
For those using Office in the browser, it seems as though Microsoft is shifting into CSOM/JSON/REST, meaning this solution is coded entirely differently than COM. This should help you get started:
https://msdn.microsoft.com/EN-US/library/office/dn268594.aspx.

Editing Documents (.doc) in Browsers

I've been developing a web application with asp.net webforms and in this app I have some documents (.doc, .docx, .rtf files), and my client want to edit these files on browser, they want to open a document in an editor, edit, save it on server (without downloading) and close it. I know it's difficult but I would like to know if it's possible or if is there any easy way to do it. We find something like SkyDrive of Microsoft.
PS: We can pay for components if you can suggest something that really works.
Thank you!
IF the clients have Office installed:
I would recommend http://www.webdavsystem.com/server - this allows you to build a "virtual filesystem" (WebDAV which is based on HTTP) which Office can access thus allowing the client to open/edit/save a document (DOCX etc.) via HTTP(S)... it is pure .NET, integrates nicely with ASP.NET and has even a JavaScript accessible API... esp. the upcoming V 3 comes with a wizard which allows you easily to add that funcionality to your ASP.NET application... (just a happy customer, not affilliated).
IF the clients don't have Office installed then it gets tricky:
To really fully support you would need some sort of Silverlight/Flash/ActiveX/JavaApplet which runs in the clients browser and supports the needed editing features...
I am not aware of such production-quality components except the ones from Microsoft - see http://www.microsoft.com/en-us/office365/online-software.aspx
You could integrate them into your web application although they won't offer the full Office feature set in the browser...

Processing Microsoft Office Outlook 2003/2007 email messages

Summary
It's been while now that I receive emails on a specific work-related domain, and I'd like to build up a database based on the information that is provided within these emails messages.
These messages are work related items about some needs and requirements in the computer science industry in my corner of the world.
I would like to parse or analyze these emails in an automatic way so that I can get recurring information into a database and build a business intelligence-like database which would keep me informed about the most demanded field of specialization.
Technological environment
O/S: Microsoft Windows 7 Pro
Office: Microsoft Office 2007 Pro
Yes, I can use .NET 4.0! =)
(I'll be pleased to provide further information as needed.)
Questions
How to access either PST files or the Outlook personal data files through the COM Interop assembly?
What are the objects to use to instantiate each of the emails found in the Outlook PST file or other?
What is the best way to go to parse an email message?
Thanks for any of you who can share her/his grain of salt in order to help me achieve my objective. That is very meaningful to me.
If you plan to use the Outlook 2007 COM object Model I suggest you start with this article: How Do I ... in Outlook
Look specifically for "Folders and Stores", "Search an Filter", "Solution Storage".
Aside from this, the PST format is now documented here: PST File Format SDK
but this is an unmaged C++ API, hard to use in .NET. There was a .NET port project initiated here: http://pstsdknet.codeplex.com/documentation but it seems quite dead (or not yet born)... so it's a difficult road to head for.

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.

Categories