Click here to Skip to main content
Licence 
First Posted 1 Jan 2004
Views 106,617
Bookmarked 27 times

Open Default mail client in .NET

By | 1 Jan 2004 | Article
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

About the Author

Melu

Web Developer

India India

Member

hi i lovvvvvvvvvvvvvvvvvvvveeeeeeeeeeeee CodeProject Wink | ;)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionWhy is this voted so low? PinmemberPak5143:54 22 Jan '09  
GeneralMy vote of 2 Pinmembermahi_19882:02 18 Dec '08  
GeneralHo to develop Same application in ASP.NEt [modified] PinmembermrMdpendable17:57 3 Jul '08  
GeneralNot working with ASP.Net and c# as code behind Pinmembershdeo1:22 18 Jul '07  
QuestionAttachment doesn't work for me PinmemberTiman Zhao21:34 28 Jun '07  
AnswerRe: Attachment doesn't work for me PinmemberTiman Zhao22:34 28 Jun '07  
GeneralLength restriction Pinmemberzespri17:22 1 Mar '06  
GeneralRe: Length restriction Pinmemberleggan5:27 22 Apr '08  
Question&body problem PinmemberRob 123451:19 23 Feb '06  
AnswerRe: &body problem PinmemberRob 1234518:21 24 Feb '06  
GeneralRe: &body problem Pinmemberclu822:54 6 Nov '08  
GeneralAttachment PinmemberSrinivasan Raju2:12 1 Sep '05  
GeneralRe: Attachment PinmemberMDT Daniel21:04 19 Sep '06  
Thanks for this example of code.
Now I just tried this, but for the Lotus Notes mail client
it doesn't start with attachment txt-file.
 
Do you have any ideas, what I can change?
 
Thanks!
 
Kind Regards
Daniel

GeneralAttachment is working !!!!! PinsussMartin Wolff2:01 22 Feb '05  
GeneralRe: Attachment is working !!!!! PinsussAnonymous4:28 6 Apr '05  
GeneralRe: Attachment is working !!!!! PinsussAnonymous14:39 10 Jul '05  
GeneralRe: Attachment is working !!!!! Pinmemberfferdinanvi14:24 22 Jul '05  
GeneralRe: Attachment is working !!!!! PinmemberRohit Divas19:05 19 Sep '05  
GeneralRe: Attachment is working !!!!! Pinmembersilkkeng14:46 26 Sep '05  
GeneralSimply the attachments cannot work! PinmemberJanko Mrkvicka3:17 19 Nov '04  
GeneralRe: Simply the attachments cannot work! Pinmembertej5107818:38 26 May '05  
Generalopen default mail client Pinmembermanojkumarsn23:23 10 Sep '04  
Generalattachment problem PinmemberKelraad4:32 12 Aug '04  

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.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 2 Jan 2004
Article Copyright 2004 by Melu
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid