Page view counter

How Do I: Use ASP.NET to Send Email from a Web Site

In this video Chris Pels shows how to create and send an email in an ASP.NET web site. First, learn about the core classes in the System.Net.Mail namespace for sending mail in an ASP.NET web site. See how to create an email message using the MailMessage class including how to use the MailAddress class for the From address and how to include one or more To addresses. Next, see how email is sent using the SmtpClient class. Finally, learn about the additional options for configuring the email message such as CC, BCC, Priority, and adding attachments.

Presented by Chris Pels

Duration: 25 minutes, 33 seconds

Date: 28 August 2008

Watch the video   |   Download the video   |   Get VB code  or  C# code

Video downloads: WMV | Zune | iPod | PSP | MPEG-4 | 3GP

Audio downloads: AAC | WMA | MPEG-4 | MPEG-3 | MPEG-2

Comments : 30

Leave a Comment

yousaid : On August 29, 2008 9:12 AM said:

Hello Chris,

The download links are crossed. The VB link points to  C# and the C# points to VB.

cheers,

yousaid

ckycn : On August 29, 2008 11:38 PM said:

not bad,the file name is clear.i get it.

thanks.

SteliosM : On September 01, 2008 1:44 AM said:

Excellent!!

It will be very handy to learn also how to use the collections.

Thanks Chris.

dw.egun1 : On September 01, 2008 2:30 AM said:

Very nicely done.

It's good video for me. Thanks

houser1 : On September 02, 2008 9:57 AM said:

Hi

thanks for video

it is very helpfull but i don't know how to make it on Vista.

do you know some place where "yellowhead" like me can teach how to make it on Vista?

houser1 : On September 02, 2008 9:58 AM said:

sorry i don't write why?

because Vista haven't got some mailClient

abelanet : On September 02, 2008 12:40 PM said:

Thanks very informative

gbeford : On September 02, 2008 12:51 PM said:

Why are all the learning videos in VB ?

aslesh : On September 03, 2008 10:22 AM said:

Thanks for the Video..

asater : On September 03, 2008 1:38 PM said:

Please, why they have to be in VB all the time?

Thank you

RajibRoy : On September 04, 2008 2:39 AM said:

Hi,

I am developing a newsletter system. You can check it from www.schooluae.com/home.aspx

But when i am sending email from webserver it shows SMTP error. but when i am send from my laptop it is ok. In webserver i have used their smtp

Please help me

Rajib

www.rajibroy.info

RajibRoy : On September 04, 2008 2:52 AM said:

Hi,

Another question, if my smtp server required Authentication(username & Password) so how i will provide that.

Waiting for the response.

Rajib

http://www.rajibroy.info

funluckykitty : On September 04, 2008 2:00 PM said:

Very nice.. wonder why no use of "Imports System.Net.Mail"

dw.egun1 : On September 16, 2008 2:27 AM said:

Nicely done. It's very helpful. Thanks.

v.hosseini2008 : On September 16, 2008 8:06 AM said:

Thanks for video.It's very helpful.

Lily Wang : On September 23, 2008 10:21 AM said:

Thanks so much for this video.  Can you also show us how to handle the attachment size check before attaching it to the e-mail.  I found the program doesn't even throw an exception when user attachs large size e-mail.  It just dies...

thanks!

CrispinH : On September 24, 2008 12:39 PM said:

This example works fine when I use my local Exchange Server but when I use the SMTP server on a Windows Server 2008 box on the same domain (this is my own remote web server over which I have total conrol), I get "Unable to read data from the transport connection: net_io_connectionclosed".

I've tried no credentials, default credentials and specific credentials.  How do I make this work?

www.ildw.com : On September 24, 2008 7:46 PM said:

how do I redirect the user when the email has been sent to  a thank you page, and when the email has not been send to an error page?

samuel24 : On September 30, 2008 4:01 AM said:

VB code n C# code is interchanged

k but even i have some error in mail

diego40 : On October 03, 2008 7:41 PM said:

I have this Server Error Application

No connection could be made because the target machine actively refused it ...

It is something about my smtp server??  Someone knows a smtp server that I can use to test it?

neerav : On October 05, 2008 1:22 AM said:

Can u exlain me how to create inbox in ur next video ?

Pakistan : On October 11, 2008 6:17 AM said:

Thanks for great video

lgbaustin : On October 17, 2008 9:54 AM said:

Thanks for this video .. it is so easy on the eyes. You have a good teaching style.

jimmyo1979 : On October 22, 2008 11:56 AM said:

Both code downloads contain the VB lanugage.  Do you have a C# version of the code?

Bluetip : On November 05, 2008 12:25 PM said:

Can we have the C# code ?

foote.greg : On November 07, 2008 3:30 PM said:

Hi Chris,

I have successfully set up my createuserwizard and the finish step that sends the email works correctly and the email is sent.  However when i try and implement the password recovery wizard that sends an email to the user the email is blocked by the smtp server with this message:

Mailbox unavailable. The server response was: Authentication is required for relay

how can one of these be denied and the other not ?

don't they both use the smtp settings in the smtp section of the web.config file ?

Here is that section of the web.config file:

 <!-- Add the email settings to the <system.net> element -->

 <system.net>

   <mailSettings>

     <smtp from="webMaster@aaaSite.com">

       <network

            host="mail.aaaSite.com"

            userName="usernameValue"

            port="25"

            password="passwordValue"  />

     </smtp>

   </mailSettings >

 </system.net>

Thanks

Greg

leksodav : On November 09, 2008 7:32 AM said:

source  code  links are swapped :) vb->cs

harishkumar.a6@gmail.com : On November 09, 2008 7:48 PM said:

Thanks for video.It's very helpful.

ZenTrickz : On November 10, 2008 6:22 PM said:

Links are not crossed.  They are both in VB

apkamble : On November 17, 2008 11:16 AM said:

The VB & the C# links both download the VB version of this application.

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities