1

I need to achieve following

1- Save email message as draft which user can later open, modify and send manually

2- Compose email and open outlook as new email and allow user to send or discard then and there

There are sample codes using both Microsoft.Office.Interop.Outlook and SmtpClient. I believe SmtpClient can not automate Outlook. And, for the second option i do not want to add reference of Microsoft.Office.Interop.Outlook because what if Office Outlook is not installed!!!

So please guide me for further readings.

Edit

Using no reference will surely enable the form to get open even if outlook is not installed and this can be checked by just checking null for oType after

Type oType = Type.GetTypeFromProgID("Outlook.Application");

What if i add reference and client opens the form and outlook is not there OR referenced library is Office 2013 and installed library is Office 2010? would the form open or throw exception OR following lines will still work?

Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();    
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
bjan
  • 2,000
  • 7
  • 32
  • 64

1 Answers1

0

You need to clarify a bit here. You say you want to automate Outlook, but not take a dependency on it. That's just weird unless you're abstracting the concept of an email client, which does not seem to be your motivation.

Assuming you do take a dependency on the interop assembly, you could check for broken/invalid references before your application actually uses that reference. See here.

Community
  • 1
  • 1
  • Suppose, i add reference and deploy the application, client don't have office, client opens the form where "email" button will do the job. client hasn't clicked email button but just opens the form. Will the form open or throw error? – bjan Aug 21 '13 at 11:28