Introduction In this article have details to open new outlook compose window using C#.now days outlook is most popular.so most of the users need send email thorugh the outlook when user click email button or option in system. Download Souce Code-CS Implemetation
This is very simple and few lines of code to implement in .NET. To this we need compose the command with email id and subject.anf then need pass this string to Process.Strart Method. Here which are this we can give as parameters 1. Email ID =info[at]codegain.com 2. Subject=The Information 3. Body=this is testing email by the administrator. 4. CC=vrrave[at]codegain.com 5. bbc=murukan[at]codegain.com
Above list has supporting keywords to pass the within the oulook. Steps 1 Open visual studio 2008 or 2005 and click new project --> select windows project under the Visual C# node and give the name as OpenOutlookDemo. Then add one button from the toolbox and change text as Email me and change the button name as btnEmail. Llok following figure. 
Then double click on button and navigate to code behind file and add using stament to access Process Object in .Net Class Libarary. {codecitation class="brush: csharp; gutter: true;" width="650px"}
using System.Diagnostics; {/codecitation} Then write code in under the button click event. {codecitation class="brush: csharp; gutter: true;" width="650px"} private void btnEmail_Click(object sender, EventArgs e) { string command = "mailto:info[at]codegain.com?subject=The Subject&bcc=vrrave[at]codegaim.com"; Process.Start(command); } {/codecitation} In above code line we need understand how to compose the command string.
1.The mailto is main part of this command. The reason is emailto knows protocol keyword. 2.The subject is support to send subject to outlook email subject textbox 3.The Body Is support to send content of the email messsage 4.The cc is support to add CC email address to this email message 5.The BCC is support add BCC email address to this email messsage.
Note: When we are concatenate the more than one argument we need use the “&” symbol. {codecitation class="brush: csharp; gutter: true;" width="650px"} string command = "mailto:info[at]codegain.com?subject=The Subject&bcc=vrrave[at]codegaim.com&cc=murukan[at]codegain.com"; {/codecitation} Step-2
Now Press F5 to run the application and press Email me button. Its bring surprise the result to you.look the folloing figure. 
Conclusion This article have detail launch the new outlook email window using C# to compose email and send.
Thank you. |