开发者

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:

  1. What tool would you use to accomplish this?
  2. Will there need to be separate code for Outlook 2003 vs. 2007?
  3. In general, using whatever tools are recommended, is this a relatively straightforward problem to solve?

Thanks for any insight.


  1. 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.
  2. 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.
  3. 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:

  1. Visual Studio Tools for Office (VSTO)

    • total control over Outlook
    • version of Outlook may matter
  2. Assuming you have Exchange, you could use WebDAV, Exchange's XML methodology

    • version of Outlook wouldn't matter here
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜