Solved

Email and ASP.net

Posted on 2013-01-20
3
403 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
3 Comments
 
LVL 6

Accepted Solution

by:
esolve earned 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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