Click here to Skip to main content
11,413,961 members (77,037 online)
Click here to Skip to main content

Open Default mail client in .NET

, 1 Jan 2004
Rate this:
Please Sign up or sign in to vote.
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

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("<A href="mailto:melroy@testmail.com">mailto:melroy@testmail.com</A>")
MsgBuilder.Append("<A href="mailto:&cc=testcc@testcc.com,testcc1@testcc.com">&cc=testcc@testcc.com,testcc1@testcc.com</A>")
MsgBuilder.Append("<A href="mailto:&bcc=testcc@testbcc.com,testcc1@testbcc.com">&bcc=testcc@testbcc.com,testcc1@testbcc.com</A>")
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

Share

About the Author

Melu
Web Developer
India India
hi i lovvvvvvvvvvvvvvvvvvvveeeeeeeeeeeee CodeProject Wink | ;)

Comments and Discussions

 
QuestionWhy is this voted so low? Pin
Pak514, 22-Jan-09 4:54
memberPak51422-Jan-09 4:54 
GeneralMy vote of 2 Pin
mahi_1988, 18-Dec-08 3:02
membermahi_198818-Dec-08 3:02 
GeneralHo to develop Same application in ASP.NEt [modified] Pin
mrMdpendable, 3-Jul-08 18:57
membermrMdpendable3-Jul-08 18:57 
GeneralNot working with ASP.Net and c# as code behind Pin
shdeo, 18-Jul-07 2:22
membershdeo18-Jul-07 2:22 
QuestionAttachment doesn't work for me Pin
Timan Zhao, 28-Jun-07 22:34
memberTiman Zhao28-Jun-07 22:34 
AnswerRe: Attachment doesn't work for me Pin
Timan Zhao, 28-Jun-07 23:34
memberTiman Zhao28-Jun-07 23:34 
GeneralLength restriction Pin
zespri, 1-Mar-06 18:22
memberzespri1-Mar-06 18:22 
GeneralRe: Length restriction Pin
leggan, 22-Apr-08 6:27
memberleggan22-Apr-08 6:27 
Question&body problem Pin
Rob 12345, 23-Feb-06 2:19
memberRob 1234523-Feb-06 2:19 
AnswerRe: &body problem Pin
Rob 12345, 24-Feb-06 19:21
memberRob 1234524-Feb-06 19:21 
GeneralRe: &body problem Pin
clu82, 6-Nov-08 3:54
memberclu826-Nov-08 3:54 
GeneralAttachment Pin
Srinivasan Raju, 1-Sep-05 3:12
memberSrinivasan Raju1-Sep-05 3:12 
GeneralRe: Attachment Pin
MDT Daniel, 19-Sep-06 22:04
memberMDT Daniel19-Sep-06 22:04 
GeneralAttachment is working !!!!! Pin
Martin Wolff, 22-Feb-05 3:01
sussMartin Wolff22-Feb-05 3:01 
GeneralRe: Attachment is working !!!!! Pin
Anonymous, 6-Apr-05 5:28
sussAnonymous6-Apr-05 5:28 
GeneralRe: Attachment is working !!!!! Pin
Anonymous, 10-Jul-05 15:39
sussAnonymous10-Jul-05 15:39 
GeneralRe: Attachment is working !!!!! Pin
fferdinanvi, 22-Jul-05 15:24
memberfferdinanvi22-Jul-05 15:24 
GeneralRe: Attachment is working !!!!! Pin
Rohit Divas, 19-Sep-05 20:05
memberRohit Divas19-Sep-05 20:05 
GeneralRe: Attachment is working !!!!! Pin
silkkeng, 26-Sep-05 15:46
membersilkkeng26-Sep-05 15:46 
GeneralSimply the attachments cannot work! Pin
Janko Mrkvicka, 19-Nov-04 4:17
memberJanko Mrkvicka19-Nov-04 4:17 
GeneralRe: Simply the attachments cannot work! Pin
tej51078, 26-May-05 19:38
membertej5107826-May-05 19:38 
Generalopen default mail client Pin
manojkumarsn, 11-Sep-04 0:23
membermanojkumarsn11-Sep-04 0:23 
Generalattachment problem Pin
Kelraad, 12-Aug-04 5:32
memberKelraad12-Aug-04 5:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150427.2 | Last Updated 2 Jan 2004
Article Copyright 2004 by Melu
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid