You must Sign In to post a response.
  • Category: ASP.NET

    server in

    how to get server send message to client using
  • #348341
    The following Sample Code is the code which can be used to send mails through ASP.Net C#.... its a working code for me.....

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.
    using System.Web.UI.HtmlControls;
    using System.Net.Mail;

    public partial class Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    protected void Button1_Click(object sender, EventArgs e)
    //Calling the function SendMail
    Response.Write( SendMail("","","","Test Mail","Test Mail Body"));

    public string SendMail(string toList, string from, string ccList, string subject, string body)
    MailMessage message = new MailMessage();
    SmtpClient smtpClient = new SmtpClient();
    string msg = string.Empty;
    MailAddress fromAddress = new MailAddress(from);
    message.From = fromAddress;
    if (ccList != null && ccList != string.Empty)
    message.Subject = subject;
    message.IsBodyHtml = true;
    message.Body = body;
    smtpClient.Host = "";
    smtpClient.Port = 25;
    smtpClient.UseDefaultCredentials = true;
    smtpClient.Credentials = new System.Net.NetworkCredential("", "password");

    msg = "Successful";
    catch (Exception ex)
    msg = ex.Message;
    return msg;


    Check this to download the working versions of files

    Thanks and Regards
    Miss Meetu Choudhary (Site Coordinator)
    Go Green Save Green

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.