sending Email in asp.net in different ways

From server(website) to mail server
-----------------------------------


import namespace <%@ Import Namespace="System.Net.Mail" >

string t="";
string msg;
msg = "";
msg += "";
msg += "
Email-Id ";
msg += TextBox1.Text;
msg += "
Contact number ";
msg += TextBox2.Text ;
msg += "
";
t=TextBox1.Text.ToString();
MailMessage mailmsg = new MailMessage();
mailmsg.From = new MailAddress(t);
mailmsg.To.Add("email08@gmail.com");
mailmsg.Subject = "Member";
mailmsg.IsBodyHtml = true;
mailmsg.Body = msg;
SmtpClient a = new SmtpClient();
mailmsg.Priority = MailPriority.High;
a.Host="localhost";
a.Send(mailmsg);

From local machine application to mail server
---------------------------------

import <%@ Import Namespace="System.Web.Mail" >

string msg;
msg = "";
msg += "";
msg += "
Email-Id ";
msg += TextBox1.Text;
msg += "
Contact number ";
msg += TextBox2.Text ;
msg += "
";

MailMessage mailmsg = new MailMessage();
mailmsg.From = TextBox1.Text.ToString();
mailmsg.To = "email08@gmail.com";
mailmsg.Subject = "Member";
mailmsg.BodyFormat = MailFormat.Html;
mailmsg.Body = msg;
mailmsg.Priority = MailPriority.High;
SmtpMail.Send(mailmsg);


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: