How to send an email in asp.net 2.0

by Kareem Allam 27. July 2011 18:12

 

Use this in web.config 

 

<system.net>
     <mailSettings>
       <smtp>
         <network 
		host="mail.domain.com" 
		port="25"  
		userName="mail@domain.com" 
		password="password"
           />     
       </smtp>
     </mailSettings>
 </system.net>

 

 

 

 Then Use this Function (VB)

 

Imports System.Net.Mail

Public Function SendMail(ByVal ToMailAddress As String, _
        ByVal FromMailAddress As String, _
        ByVal Subject As String, _
        ByVal Body As String, _
        ByVal IsHTML As Boolean) As Boolean
 
        Try
 
            Dim objMsg As New MailMessage(FromMailAddress, ToMailAddress)
 
            objMsg.IsBodyHtml = True
            objMsg.Body = Body
            objMsg.Subject = Subject
            Dim smtp As New SmtpClient
            smtp.Send(objMsg)
            SendMail = True
 
        Catch
            SendMail = False
        End Try
    End Function 


 

 

P.S.

This mail will  be sent in HTML format. The ASP's controls that I am using  are some text boxes and button send and validation controls for the required fields.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Comments (26) -

osama safwat
osama safwat Egypt
8/8/2011 10:02:58 AM #

thanks a lot
that is very useful and thanks for admin

bucino ulje
bucino ulje United States
8/8/2011 5:04:51 PM #

I definitely wanted to write down a simple word to appreciate you for all of the precious steps you are giving out at this website. My rather long internet lookup has finally been recognized with reasonable ideas to share with my classmates and friends. I 'd declare that we website visitors actually are unequivocally blessed to exist in a great community with  many wonderful people with valuable ideas. I feel truly blessed to have encountered the webpages and look forward to tons of more pleasurable moments reading here. Thanks a lot once more for all the details.

strony internetowe Radom
strony internetowe Radom United States
8/8/2011 6:39:59 PM #

Very interesting thread on the forum would be more such interesting discussion was on the internet

You share a lot helpful ideas! Perhaps I should think of trying to do this myself.

Lionel Asevedo
Lionel Asevedo United States
8/8/2011 11:55:04 PM #

Nice and informative.Thanks for sharing.

implantate berlin
implantate berlin United States
8/9/2011 12:34:29 PM #

REally nice blog.I really like your research and quality of work.

Nathanael Breslauer
Nathanael Breslauer United States
8/9/2011 6:34:28 PM #

Hi good blog and helpful.Thanks!!

How to get Fuller Eyelashes
How to get Fuller Eyelashes United States
8/9/2011 9:13:28 PM #

Heya just wanted to tell you that amazing web site.

Micheline Mebus
Micheline Mebus United States
8/9/2011 11:23:54 PM #

Nice share!! I Love to read this kind of post.

link building service effective
link building service effective United States
8/10/2011 2:18:31 AM #

There are some attention-grabbing closing dates in this article but I don’t know if I see all of them center to heart. There may be some validity but I will take hold opinion until I look into it further. Good article , thanks and we wish more! Added to FeedBurner as properly

Mocmed
Mocmed United States
9/15/2011 7:30:47 AM #

Great ....You have beautifully presented your thought in this blog post.

SJR Luxuria Prices
SJR Luxuria Prices United States
9/16/2011 9:27:35 AM #

Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.

Omar
Omar
9/18/2011 8:11:36 AM #

Thanks  for the great article. I just bookmarked your website and look forward to returning from occasionally to read more.

Regards

silver paint
silver paint United States
9/28/2011 11:22:35 PM #

Hey there!! This is a real cool site!!

Connor
Connor United States
10/10/2011 8:26:44 PM #

Hi, outstanding site. I like your theme. I just got carried out with cosmetic courses and wish to set up my own personal site. Thank you for the great publish!

mats
mats
10/16/2011 1:28:49 AM #

Hi this is a Great info i like this thanks

burton school backpacks
burton school backpacks United States
10/16/2011 5:57:45 PM #

It was awesome to read through your posting. I personally loved the couple of minutes i spent reading through it and want to leave a comment to express that....All the best

Fred
Fred United States
10/17/2011 7:29:22 PM #

Merci pour ce post.

Deepak
Deepak India
10/20/2011 2:23:29 PM #

Good articles or blog posts and it is so very helpful.

Windows Hosting M6.Net
Windows Hosting M6.Net United States
10/20/2011 7:09:33 PM #

Great blog. Follow this for future reference.

Dustin Bergmark
Dustin Bergmark United States
10/25/2011 4:51:57 AM #

Thank you for your insightful comments. I hope to visit your website soon.

Chris
Chris
10/31/2011 12:06:01 AM #

Some great Information here. Thank you very much

Web Directory
Web Directory United States
11/2/2011 10:58:47 AM #

Thank you for an additional terrific write-up. Exactly where else could anybody get that type of information and facts in this kind of a perfect way of writing? I've a presentation subsequent week, and I am on the look for like information.

Web Directory
Web Directory United States
11/3/2011 6:48:27 AM #

Took me time to understand every single comments, but I surely enjoyed the post. It proved being Extraordinarily valuable to me and I’m positive to all of the commenters here! It is usually effective when probable not only be informed, but also entertained!

payer en ligne
payer en ligne France
11/6/2011 9:43:10 PM #

Merci pour ce petit article sympathique, je repasserai certainement de temps en temps maintenant !

pacquiao vs marquez 3 replay
pacquiao vs marquez 3 replay United States
11/13/2011 6:09:40 AM #

your blog is really amazing........

About EgDev.com

If you would like to find value services with excellent quality and cost effectiveness and with a focus on speed , Just Follow

 Egypt Development Freelance Team.

Month List

Page List