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

    How can we solve this problem in ASP.NET

    Hi,

    1)Can anyone guide me or help me, how to write a code to sent a mail.
    2)How to store the message the particular date and time in the database(sqlserver).
    3)How to user the animation effect,password strength,dynamic populate and slider extender in asp.net
  • #705881
    To get email sending code see below link:
    http://dotnetsquare.com/resources/1-easy-way-to-send-email-withwithout-attachment-using-Asp-Net-C-Sharp-net-or-VB-Net.aspx

    If it helps you then Rate this.

    Best Regards,
    Manoranjan Sahoo
    http://www.dotnetsquare.com
    Blog: http://blog.msahoo.net

  • #705886
    Hi deepak,

    check this below code for sending main in asp.net using smtp protocol and MailMessage class.



    MailMessage mail = new MailMessage();
    mail.To.Add("Email ID where email is to be send");
    mail.To.Add("Another Email ID where you wanna send same email");
    mail.From = new MailAddress("YourGmailID@gmail.com");
    mail.Subject = "Email using Gmail";

    string Body = "Hi, this mail is to test sending mail"+
    "using Gmail in ASP.NET";
    mail.Body = Body;

    mail.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
    smtp.Credentials = new System.Net.NetworkCredential
    ("YourUserName@gmail.com","YourGmailPassword");
    //Or your Smtp Email ID and Password
    smtp.EnableSsl = true;
    smtp.Send(mail);



    check this link http://csharpdotnetfreak.blogspot.com/2009/08/send-email-using-gmail-in-aspnet.html

    Regards
    Sekhar Babu,
    www.aspdotnet-sekhar.blogspot.in

  • #705889
    Hi,

    Follow below answers and my resource to solve your requirement

    1)Can anyone guide me or help me, how to write a code to sent a mail.

    use below code to send email from webpage

    using System.Net;
    using System.Net.Mail;
    public partial class MailPrgm : System.Web.UI.Page
    {
    string frmgmail = "yourid@gmail.com";
    string frmpwd = "yourgmailpwd";

    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    try
    {
    MailMessage msg = new MailMessage();
    msg.To.Add( "Toid@anydomain.com"); //change to id here
    //use below line when you want ad attachment
    //msg.Attachments.Add(new Attachment("file full path"));

    //if your email is html content then set true in below line
    msg.IsBodyHtml = true;
    msg.Body = mailContent;
    SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
    NetworkCredential NetCrd = new NetworkCredential(frmgmail, frmpwd);
    mailClient.UseDefaultCredentials = false;
    mailClient.Credentials = NetCrd;
    mailClient.EnableSsl = true;
    mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    mailClient.Send(msg);
    clear();
    Label1.Text = "Mail Sent Successfully";
    }
    catch (Exception ex)
    {
    Label1.Text = "Unable to send Mail Please try again later";
    }
    }
    }


    2)How to store the message the particular date and time in the database(sqlserver).


    using System.Data;
    using System.Data.SqlClient;
    public partial class InsertNewRecord : System.Web.UI.Page
    {
    //Decalre SQL Server connection details
    SqlConnection sqlcon=new SqlConnection(@"Server=SQLEXPRESS;database=test;uid=xxxx;pwd=yyyy;"); //your server details
    SqlCommand sqlcmd=new SqlCommand();
    protected void Button1_Click(object sender, EventArgs e)
    {
    //Here your mail or any code
    SqlCommand sqlcmd = new SqlCommand("insert into mailsentdetails(fromid,toid,date,time,status) values ('from id','to id','" & DateTime.Now.ToString("yyyy-MM--dd") & "','" & DateTime.Now.ToString("HH:mm:ss") & "','y')", sqlcon); //change this static values as per requirement
    sqlcmd.CommandType = CommandType.Text;
    sqlcon.Open();
    sqlcmd.ExecuteNonQuery();
    sqlcon.Close();
    }
    }


    3)How to user the animation effect,password strength,dynamic populate and slider extender in asp.net

    For the above question refer my this two resources here

    Processing example
    http://www.dotnetspider.com/resources/42980-How-show-progress-bar-ASP-Net.aspx

    slider example
    http://www.dotnetspider.com/resources/43508-How-create-Slider-ASP-NET-using-AJAX.aspx

    Regards
    N.Ravindran
    Your Hard work never fails

  • #705909
    Hai Deepak,
    See the inline answers of your questions below:
    1) Can anyone guide me or help me, how to write a code to sent a mail.
    A. To write the code for sending the mails, you need to use the System.Net.Mail.dll and the using system.Net.Mail namespace to your code file.
    After that you can write the code for sending mails as:

    protected void btnSendMail_Click(object sender, EventArgs e)
    {
    MailMessage m = new MailMessage("From_Mail_Id","To_Mail_Id","Message_Content","attachement_file");
    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
    smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
    try
    {
    smtpClient.Send(m);
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.ToString() );
    }
    }


    2) How to store the message the particular date and time in the database (sqlserver).
    A. To store the message at the particular date and time, while inserting the records, you can insert the current date and time to the sql server database table.
    So it will store the time on which the message got send and you can track it later.

    3) How to use the animation effect, password strength, dynamic populate and slider extender in asp.net
    A. To use the slider extender, you need to use the Ajax Toolkit controls. Animation effect, you can use Marquee, For password strength, use some algorithm like SHA1 or some cryptographic algorithm.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #705935
    Hi,

    Try like this to send a mail,



    protected void SendMail()
    {
    // Gmail Address from where you send the mail
    var fromAddress = "XXX@gmail.com";
    // any address where the email will be sending
    var toAddress = YYY.Text.ToString();
    //Password of your gmail address
    const string fromPassword = "Password";
    // Passing the values and make a email format to display
    string subject = YourSubject.Text.ToString();
    string body = "From: " + YourName.Text + "\n";
    body += "Email: " + YourEmail.Text + "\n";
    body += "Subject: " + YourSubject.Text + "\n";
    body += "Leave Req: \n" + Comments.Text + "\n";
    // smtp settings
    var smtp = new System.Net.Mail.SmtpClient();
    {
    smtp.Host = "smtp.gmail.com";
    smtp.Port = 587;
    smtp.EnableSsl = true;
    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
    smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, subject, body);
    }




    For storing the data for particular date and time,

    Create one table in DB with required columna and store the data with datetime.

    Regards,
    Gandhi


  • 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.