starting an outlook email from inside a win form in C#

Good morning,,
I created an application in C# where, at some point, the user will need to use outlook  to send an email to a colleague.

The email address of the percipient as well as the body and subject matter are placed in text boxes in the win form waiting to be moved or copied to the outgoing email in Outlook.

So, basically my question is: how do I run outlook form inside a win form, select a new email copy the recipient email address and the body of text into the email and send it.

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use outlook object to create the new email item with selected values
The only trick is not to call item.send instead call item.display this will show message window to user
adamtraskAuthor Commented:
FarWest: Would you give me an example, please?

Thank you
adamtraskAuthor Commented:
What namespace of reference do I need to use...?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

OK . I will send it once I get back to my computer
the namespace is Outlook = Microsoft.Office.Interop.Outlook;
this sample assumes use this statement, also the sample use html template so you can make layout without complicating the code

using Outlook = Microsoft.Office.Interop.Outlook;

     private void SendEmail()
            String htmlTemplate = File.ReadAllText("myTemplate.html");

                Outlook.Application outlook = new Outlook.Application();
                Outlook._MailItem outLookMailMessage = outlook.CreateItem(Outlook.OlItemType.olMailItem) as Outlook._MailItem;
                outLookMailMessage.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
                htmlTemplate = htmlTemplate.Replace("##Text##", tbBody.text); ' replace this magic string in template
                outLookMailMessage.HTMLBody = htmlTemplate;
                outLookMailMessage.Subject = tbSubject.Text;
                outLookMailMessage = null;

            catch (System.Exception ex)


Open in new window

adamtraskAuthor Commented:
This is one of the problems: I actually found several examples of code which list the namespace you give but II try using it I get a red line under the "Office" part... I am attaching a screen shot. Thanks.outlook.jpg
adamtraskAuthor Commented:
I should add that i am using Visual Studio 2010
adamtraskAuthor Commented:
OK, I now know how to add a reference to the project.... and will be able to try your code. Thank you for your patience FarWest...
Nevermind . you are welcome  and sorry for not  mentioning the reference  part
Éric MoreauSenior .Net ConsultantCommented:
adamtraskAuthor Commented:
Thank you both...

I couldn't respond during the weekend because I don't have access to Outlook at home. Now that I am back in the office I was able to test what I got from you and a lot of other code I found online.
Finally I was able to do what I needed with the following piece of code which I would like to share with others who might find a need for it:

 private void CreateMailItem()
            Outlook.Application outlookApp = new Outlook.Application();
            Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
            mailItem.Subject = this.txtSubject.Text;
            mailItem.To = txtAddress.Text;
            mailItem.Body = txtBody.Text;
            mailItem.Importance = Outlook.OlImportance.olImportanceLow;
Éric Moreau: Right now I don't plan to include attachments to my code, but I am sure your article will be of help at some point in the future. Thank you

Éric MoreauSenior .Net ConsultantCommented:
even if you don't have attachments, everything else remains valid!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adamtraskAuthor Commented:
Thank you guys.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.