[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Email and ASP.net

Posted on 2013-01-20
3
Medium Priority
?
415 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

656 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