Open Outlook email window using C#

No.of Views5626
Bookmarked2 times
Downloads 
Votes0
By  RRaveen   On  15 Feb 2010 22:02:47
Tag : CSharp , Miscellaneous
Open Outlook email window using C#
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

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.

Image loading...

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.

Image Loading.....


Conclusion
This article have detail launch the new outlook email window using C# to compose email and send.

Thank you.

 
Sign Up to vote for this article
 
About Author
 
RRaveen
Occupation-Software Engineer
Company-TGS
Member Type-Gold
Location-Singapore
Joined date-03 Jun 2009
Home Page-codegain.com
Blog Page-www.codegain.com
- B.Sc. degree in Computer Science. - 4+ years experience in Visual C#.net and VB.net - Obsessed in OOP style design and programming. - Designing and developing Network security tools. - Designing and developing a client/server application for sharing files among users in a way other than FTP protocol. - Designing and implementing GSM gateway applications and bulk messaging. - Windows Mobile and Symbian Programming - Having knowledge with ERP solutions
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top