Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to send email,recieving,alerts,messages through from asp.net web aplication
Posted
Updated 6-Feb-12 19:25pm
v2

 
Share this answer
 
See
lots of Code Project Results
 
Share this answer
 
Try using the following code, hope it will work. Change credentials (UserName & Password) and receiver address according to yours

 SmtpClient client = new SmtpClient();
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
Try using the following code, hope it will work. Change credentials (UserName & Password) and receiver address according to yours       

 client.EnableSsl = true;
        client.Host = "smtp.gmail.com";
        client.Port = 587;
        
        // setup Smtp authentication
        System.Net.NetworkCredential credentials =
            new System.Net.NetworkCredential("gmailusername@gmail.com", "gmailpassword");
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;
 
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("gmailusername@gmail.com");
        msg.To.Add(new MailAddress("xyz@gmail.com"));
        msg.Subject = "This is a test Email subject";
        msg.IsBodyHtml = true;
        msg.Body = string.Format("<html><head></head><body>Test HTML Email</body>");
        try
        {
            client.Send(msg);
            //lblMsg.Text = "Your message has been successfully sent.";
        }
 
        catch (Exception ex)
        {
            //lblMsg.ForeColor = Color.Red;
            //lblMsg.Text = "Error occured while sending your message." + ex.Message;

        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900