5,691,626 members and growing! (11,861 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » How To     Intermediate

Open Default mail client in .NET

By Melu

hi i wanted to write an application where i could open my browsers default mail client, i was unable to find any thing in .NET hence this code.. enjoy
VB.NET 1.0, .NET 1.1, Win2K, WinXP, Win2003, Windows, .NET, ASP.NET, Visual Studio, Dev

Posted: 1 Jan 2004
Updated: 1 Jan 2004
Views: 66,988
Bookmarked: 19 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
29 votes for this Article.
Popularity: 2.57 Rating: 1.75 out of 5
20 votes, 69.0%
1
1 vote, 3.4%
2
2 votes, 6.9%
3
2 votes, 6.9%
4
4 votes, 13.8%
5

Introduction


I was writing an emailing application in VB.NET when I came across a situation where I needed to load the default email client of the user's machine with all the email fields filled up.  I was not able to find a suitable solution for this on the Internet hence I thought why not write one.  It is easy to understand.  For comments please mail me at Melroy_Britto@Hotmail.com

 

Building The Message

public class OpenDefaultClient
Function openclient()
'string builder used for concatination
Dim MsgBuilder As New System.Text.StringBuilder
MsgBuilder.Append("mailto:melroy@testmail.com")
MsgBuilder.Append("&cc=testcc@testcc.com,testcc1@testcc.com")
MsgBuilder.Append("&bcc=testcc@testbcc.com,testcc1@testbcc.com")
MsgBuilder.Append("&subject=this is test subject")
MsgBuilder.Append("&body=this is test body")
MsgBuilder.Append("&Attach="c:\mailattach.txt")
'Debug.WriteLine(MsgBuilder.ToString)
ExecuteFile(MsgBuilder.ToString)
End Function 

Starting The Default Email Client

Private Function ExecuteFile(ByVal FileName As String) As Boolean
Dim myProcess As New Process
myProcess.StartInfo.FileName = FileName
myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.RedirectStandardOutput = False
myProcess.Start()
myProcess.Dispose()
End Function
End 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Melu


hi i lovvvvvvvvvvvvvvvvvvvveeeeeeeeeeeee CodeProject Wink
Occupation: Web Developer
Location: India India

Other popular .NET Framework articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
GeneralHo to develop Same application in ASP.NEt [modified]membermrMdpendable18:57 3 Jul '08  
GeneralNot working with ASP.Net and c# as code behindmembershdeo2:22 18 Jul '07  
QuestionAttachment doesn't work for mememberTiman Zhao22:34 28 Jun '07  
AnswerRe: Attachment doesn't work for mememberTiman Zhao23:34 28 Jun '07  
GeneralLength restrictionmemberzespri18:22 1 Mar '06  
GeneralRe: Length restrictionmemberleggan6:27 22 Apr '08  
Question&body problemmemberRob 123452:19 23 Feb '06  
AnswerRe: &body problemmemberRob 1234519:21 24 Feb '06  
GeneralRe: &body problemmemberclu823:54 6 Nov '08  
GeneralAttachmentmemberSrinivasan Raju3:12 1 Sep '05  
GeneralRe: AttachmentmemberMDT Daniel22:04 19 Sep '06  
GeneralAttachment is working !!!!!sussMartin Wolff3:01 22 Feb '05  
GeneralRe: Attachment is working !!!!!sussAnonymous5:28 6 Apr '05  
GeneralRe: Attachment is working !!!!!sussAnonymous15:39 10 Jul '05  
GeneralRe: Attachment is working !!!!!memberfferdinanvi15:24 22 Jul '05  
GeneralRe: Attachment is working !!!!!memberRohit Divas20:05 19 Sep '05  
GeneralRe: Attachment is working !!!!!membersilkkeng15:46 26 Sep '05  
GeneralSimply the attachments cannot work!memberJanko Mrkvicka4:17 19 Nov '04  
GeneralRe: Simply the attachments cannot work!membertej5107819:38 26 May '05  
GeneralHIsussAnonymous0:01 1 Oct '04  
Generalopen default mail clientmembermanojkumarsn0:23 11 Sep '04  
Generalattachment problemmemberKelraad5:32 12 Aug '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 1 Jan 2004
Editor: Marc Clifton
Copyright 2004 by Melu
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project