How To Automate Outlook Mail in a Web Application utilizing .net


i have a government client that I develop a web application for.  They have a requirement that needs the web application to utilize the clients Microsoft outlook to send mail with attachments.  Do to the nature of this government client we have to use there outlook rather than other mail options because of the DOD's methods for encryption of attachments on email.  

We need the application to basically just open up outlook from our web application - populate the attachments and other items - and then send the mail - so that the PKI within the clients outlook is utilized.  We CANNOT install Outlook on the application server since this is a DOD server.  

Is this possible to do.  Please remember that this is a web application - Outlook 2007 - we are coding in C# but i will accept VB solutions as I can convert them myself.

Thank you in advance!!!!
LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?
So you want to hit the EXCHANGE Server to send the mail. You can use SMTP/MAPI. - Just for reference.

From C#, I will prefer system.Net.Mail


1. Get the SMTP credentails from the server hosting company (SMTP IP/Name, USer, Password, Port)

2. Compose the mail using system.Net.Mail in C# and send the mail.

Now, your security will not broken (Since you are targetting the SMTP Server).

Here, No need to populate outlook on click/No outlook installation.

As I said, Outlook is just a client for mail server and it just fetch/send mails from/to the mail server.

Your requirement is not clear.  Outlook is the mail client, You want the replacement web app for that client, Right?

i.e. You want to read mails from their Mail server, Is it?
Robb HillSenior .Net DeveloperAuthor Commented:

When they are using my web application......lets say they press a button that sais ...."email"  ....I need my c# code to open the default mail client - which in this case will be Outlook 2007.  Then populate the attachments, send to, cc, comments ....body...etc .....basically automate the process they would normally do manually. And then send the mail.

I have seen code out on the internet that does this but it all seems to require Outlook to be installed on the server where the web application lives...and we cannot do this since we do not have access to the DOD servers or there mail client.

We have to use Outlook to do this though do to the encrypition the DOD uses when sending mail.

Does that sound more clear?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

You want to send the automate mail, Is it?

Where did u have the attachment files, From ID and TO id?
Robb HillSenior .Net DeveloperAuthor Commented:
Just assume there are some files in a folder on the local drive.  The program needs to utilize outlook to send mail using outlook and be able to attach files.

How to you code this with .net....for a web form?
Robb HillSenior .Net DeveloperAuthor Commented:
No your not answering my question.

1)  I cannot install Outlook on the Server

2)  I have to use Outlook on the client - because of the Certificate and Encryption that is in Outlook for attachments.

3)  I need to achieve the automation of creating and sending the email using and vb or

4)  This is a web application.

I am very familiar with the library...that method does not use the PKI Cert / Encryption that Outlook has for attachments.

See my previous post fully. With MAPI you can. But, through web application, consuming a clients critical info will be a security issue and OS may block the same. I will not recommend this technique at any cost.
Robb HillSenior .Net DeveloperAuthor Commented:
I couldnt go with any of these solutions....

We couldnt use mapi.....we couldnt put outlook on server...we couldnt use a javascript and activex solution....

Since we were out of the domain we basically couldnt do anything that allowed us to utilize their outlook client which basicaly allows their security paradigm to persist.

Oh well.....I am still giving points to you all as all of your solutions are valuable informatin on most Outlook mail and .net related scenarios.  ...just not mine:)
Robb HillSenior .Net DeveloperAuthor Commented:
This solution does not work for my initial question...only keeping it for the effort and it can be helpfull for most other .net email questions.  The mapi solution was not explained very well.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.