?
Solved

Email and ASP.net

Posted on 2013-01-20
3
Medium Priority
?
412 Views
Last Modified: 2013-01-22
I am writing my first ASP.net web application with Web Developer Express 2010 and MS SQL 2008 Express. I have built a page in which a user can input details of software that is required to be deployed, I would like to create a button with the code behind it to send an email with the details of the task that has just been input, or at the least an email to state their is a task waiting.

How can I do this ?
0
Comment
Question by:ndr-itsolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
esolve earned 1600 total points
ID: 38798314
This is probably the easiest:

using System.Net.Mail;

MailMessage message = new MailMessage();
            message.From = new MailAddress("sender@mydomain.com");

            message.To.Add(new MailAddress("recipient1@mydomain.com"));
            message.To.Add(new MailAddress("recipient2@mydomain.com"));
            message.To.Add(new MailAddress("recipient3@mydomain.com"));

            message.CC.Add(new MailAddress("carboncopy@mydomain.com"));
            message.Subject = "This is my subject";
            message.Body = "This is the content";
            //message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient("smtp.mydomain.com");
            client.Send(message);

Depending on the host you might need authentication:

   SmtpClient smtp = new SmtpClient();
   smtp.Host = "smtp.gmail.com";
   smtp.Port = 587;
   smtp.EnableSsl = true;
   smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
   smtp.UseDefaultCredentials = false;
   smtp.Credentials = new System.Net.NetworkCredential(fromAddress.Address,fromPassword);


theres some more info here:

http://forums.asp.net/t/971802.aspx
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx
http://support.microsoft.com/kb/310273
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 38799920
hi

  Dim message1 As New MailMessage("kns@kockw.com", TL_Email, "Temporary Gate Pass Request needs Approval", commen)
                    message1.IsBodyHtml = True

                    Dim emailClient As New SmtpClient("put your smtp")


'some time u need to provide some credintial like this
   '  Dim basicAuthenticationInfo As _
                    'New System.Net.NetworkCredential("your email", "your password")

                    '  emailClient.UseDefaultCredentials = False
                    '  emailClient.Credentials = basicAuthenticationInfo



 emailClient.Send(message1)
0
 
LVL 10

Expert Comment

by:Monica P
ID: 38799945
To send a Email..include needed namespace...

Imports System.Net.Mail

CAll the Below function name "sendemail" inside button click

Public Sub sendemail()
        Try

            Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            ' Dim attachment As System.Net.Mail.Attachment
            SmtpServer.Credentials = New  _
              Net.NetworkCredential("Username", "Password")
            SmtpServer.Port = 587
            SmtpServer.Host = "123.122.111.111"

            mail = New MailMessage()

            mail.From = New MailAddress("Reports@test.com")
            mail.CC.Add("dmc@test.com")
            mail.To.Add("abcr@tt.com")
            mail.Bcc.Add("akila@tt.com")

            mail.Subject = "Report of Stock"
            mail.Body ="Incllude body of email..by reading the value from DATABASE"
            SmtpServer.Send(mail)
        Catch ex As Exception
        End Try
    End Sub
0

Featured Post

Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question