locked
Sending Email VS 2005 RRS feed

  • Question

  • User1839279675 posted

    I've upgraded a VS2003 web app to VS 2005, this is the code I used to use to send email for 2003.  I'm not sure how to convert this to send email in 2005 can anyone help?

     

    email.To = "MyValidEmailAddress"

    email.From = "usersValidEmailAddress"

    email.Body = "A body of text"

    email.Subject = "A line of text"

    email.BodyFormat = Web.Mail.MailFormat.Text

    System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.3"

    System.Web.Mail.SmtpMail.Send(email)

     

    Wednesday, November 26, 2008 4:27 AM

Answers

  • User1624600859 posted

     

    try this :-

    string sender="uservalidemailaddress";

     System.Net.Mail.MailMessage mMsg=new System.Net.Mail.MailMessage();

    mMsg.To.Add("myvalidemailaddress"); 

    System.Net.Mail.MailAddress mAdd=new  System.Net.Mail.MailAddress(sender);

    mMsg.From=mAdd;


    mMsg.Subject="Email subject here";

    mMsg.Body="Email text here";

    mMsg.IsBodyHTML= true;

    System.Net.NetworkCredential mNCred=new  System.Net.NetworkCredential("userid","Password");

    SmtpClient mSClnt=new  SmtpClient();

    mSClnt.UseDefaultCredentials = false;
    mSClnt.Credentials = mNCred;
    mSClnt.Host = "hostname here";
    mSClnt.Send(mMsg);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 8:02 AM

All replies

  • User1624600859 posted

     

    try this :-

    string sender="uservalidemailaddress";

     System.Net.Mail.MailMessage mMsg=new System.Net.Mail.MailMessage();

    mMsg.To.Add("myvalidemailaddress"); 

    System.Net.Mail.MailAddress mAdd=new  System.Net.Mail.MailAddress(sender);

    mMsg.From=mAdd;


    mMsg.Subject="Email subject here";

    mMsg.Body="Email text here";

    mMsg.IsBodyHTML= true;

    System.Net.NetworkCredential mNCred=new  System.Net.NetworkCredential("userid","Password");

    SmtpClient mSClnt=new  SmtpClient();

    mSClnt.UseDefaultCredentials = false;
    mSClnt.Credentials = mNCred;
    mSClnt.Host = "hostname here";
    mSClnt.Send(mMsg);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 8:02 AM
  • User1624600859 posted

     

    try this :-

    string sender="uservalidemailaddress";

     System.Net.Mail.MailMessage mMsg=new System.Net.Mail.MailMessage();

    mMsg.To.Add("myvalidemailaddress"); 

    System.Net.Mail.MailAddress mAdd=new  System.Net.Mail.MailAddress(sender);

    mMsg.From=mAdd;


    mMsg.Subject="Email subject here";

    mMsg.Body="Email text here";

    mMsg.IsBodyHTML= true;

    System.Net.NetworkCredential mNCred=new  System.Net.NetworkCredential("userid","Password");

    SmtpClient mSClnt=new  SmtpClient();

    mSClnt.UseDefaultCredentials = false;
    mSClnt.Credentials = mNCred;
    mSClnt.Host = "hostname here";
    mSClnt.Send(mMsg);

    Wednesday, November 26, 2008 8:04 AM