Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear

Please help me to find the confirmation email
to a newly registered user.
to verify he or she is entered email address is valid

thank you.

Quick reply please
Posted

Add this 2 namespaces
using System.Net;
using System.Net.Mail;
C#
try
{
SmtpClient client = new SmtpClient("smtp.gmail.com");
MailMessage message = new MailMessage("your's e-mail id(xyz@gmail.com)","e-mail id of the person you want to send mail" );
message.Body = "Body";
message.Subject = "Subject";
client.Credentials = new System.Net.NetworkCredential("Your gmail login(xyz)", "gmail password");
client.Port = Convert.ToInt32("587");
client.Send(message);
MessageBox.Show("Mail delivered successfully!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Message could not be sent.\nThe following error was returned:\n’" + ex.Message + "‘", "Sending Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

this is working perfectly on my system.
 
Share this answer
 
v2
Comments
Jagadeesh Bollabathini 30-Dec-11 2:59am    
Thank you
Very similar question roughly ½ hour ago. Have you already checked it: i want to send a mail through asp.net application[^]
 
Share this answer
 
follow this steps.

1. take that register person email,username,password.
2. on submit button write this code.
C#
MailMessage mail = new MailMessage();
      mail.To=email
      mail.From = u r company support mail
      mail.Subject = u r msg as a subject
      mail.Body =write u r text what u say.(wishes)
      mail.BodyFormat=MailFormat.Html
      mail.SmtpServer = "u r server no"
      smtp.Send(mail);

      Label1.Text = "Send message Succesfully";
  }
 
Share this answer
 
v2
Do like this
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Mail;
using System.Net;
using System.Net.Mail;
using System.IO;
C#
public partial class Support : Page
{
 protected void Page_Load(object sender, EventArgs e)
    {
  string Fullname = txtFullName.Text;
                string DepartmentDivision = txtDepartment.Text;
                string Piriority = ddlpriority.SelectedItem.Text;
                SmtpClient serverobj = new SmtpClient();
                serverobj.Timeout = 100;
                serverobj.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["Username"].ToString(), ConfigurationManager.AppSettings["UserPass"].ToString());
                serverobj.Port = System.Convert.ToInt32(ConfigurationManager.AppSettings["Port"].ToString());
                serverobj.Host = ConfigurationManager.AppSettings["HostName"].ToString(); ;
                serverobj.EnableSsl = false;            
                obj = new System.Net.Mail.MailMessage();
                obj.From = new MailAddress(txtEmail.Text, "Support Query", System.Text.Encoding.UTF8);
                obj.To.Add(ConfigurationManager.AppSettings["Username"]);             
                obj.Priority = System.Net.Mail.MailPriority.High;
                obj.Subject = txtsubject.Text;
                obj.Body = " Name:" + Fullname + "," + "\n" + "EmailId:" + txtEmail.Text + "" + "\n" + "DepartMent:" + DepartmentDivision + "" + "\n" + "Piriority:" + Piriority + "" + "\n" + "Subject:" + txtsubject.Text + "" + "\n" + "Description:" + ASPxMemo1.Text + "";

}

}




in web config:
HTML
<appSettings>
 <add key="HostName" value="gmail.com" />
    <add key="Port" value="587" />
    <add key="EmailFrom" value="anil@gmail.com" />
    <add key="Username" value="anil@gmail.com" />
    <add key="UserPass" value="password" />
 </appSettings>

 <system.net>
    <mailSettings>
      <smtp from="anil@gmail.com" deliveryMethod="Network">
        <network host="anil@gmail.com" defaultCredentials="true" userName="username" password="password" />
      </smtp>
    </mailSettings>
  </system.net>




Try this it will work

Regards,

Anilkumar.D
 
Share this answer
 
v2

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