Email programming
1)
Email is provide a
communication between one system to an other system
2)
Types of email- 1.generic mail 2.domain mail
Generic mail:- it is
a common mail (yahoo, gmail)all generic mail
Domain mail:-it
representing to company/organization mail(contact@tcs.com,info@hcl.com )etc
How to use email
programming in .net framework
There are following
step is used to communicate email in .net framework
Step1.include email
library. (using system.net.mail)
Step2. Create email object 1)mailmessage object
Step3. Verify your
mail id (change password or two steps verification )
Verify Your Gmail Account
àgo to your gmail accountàclick on manage your
google accountàclick on securityàHow you sign in to Googleà2
step verificationàverify by entering your correct passwordàenter
on app passwordat at the bottom of pageàselect app(other(custome
name))enter name of app like asp.netàclick on generate buttonàthere
will be generate 16 digit code àcopy that code and use in the program on the
place of mail passwordàrun the program
using
System.Net.Mail;
MailMessage msg = new MailMessage();
SmtpClient smtp1 = new
SmtpClient();
//how to use mailmessage object
msg.To.Add(TextBox1.Text);
msg.From=new MailAddress("abc@gmail.com");//your mail id
msg.Subject
= "this is testing mail";
msg.Body = "dear user thanks for visit my website";
//how to set html formate
msg.IsBodyHtml
= true;
//how to use smtp object
..set host(server)gmail.com, yahoo.com etc
smtp1.Host
= "smtp.gmail.com";
smtp1.port=587
//hset the credentials
smtp1.Credentials = new System.Net.NetworkCredential("abc@gmail.com",
"xxxtvxbkfvggthgr");
//enable sss certificate
smtp1.EnableSsl = true;//(only work https domain)
//send mail using smtp object
smtp1.Send(msg);//pass mailmessage object
https://www.google.com/settings/security/lesssecureapps
Domain Mail concept
SmtpClient smtpClient = new SmtpClient("nrsolution4u-student.com",
587);//outgoing port 587, incoming port 110
smtpClient.Credentials = new System.Net.NetworkCredential("contact@nrsolution4u-student.com",
"password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
// smtpClient.EnableSsl = true;
MailMessage mailMessage = new
MailMessage("contact@nrsolution4u-student.com",
TextBox1.Text.Trim());
mailMessage.Subject = "Domain
Testing";
mailMessage.Body = "this is domain mail
testing";
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);
Label1.Text
= "email send successfully";