sending email ASP C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wassssup
    New Member
    • Oct 2007
    • 47

    sending email ASP C#

    i want to send an email using asp.net in c# below is the code:
    the error that i get in the browser:"The transport failed to connect to the server."
    Code:
           MailMessage mail = new MailMessage();
            mail.To = toTxt.Text;
            mail.From = fromTxt.Text;
            mail.Subject = subjectTxt.Text;
            mail.Body = bodyTxt.Text;
            try
            {
                SmtpMail.SmtpServer = "smtp.gmail.com";
                            //i even put localhost but doesnt work
                SmtpMail.Send(mail);
            }
            catch (System.Web.HttpException ex)
            {
                 Response.Write(ex.Message);
            }
    when i change the port to 25 from vs2005 under the properties, it couldent even display the page

    please advise, thanks in advance.
    Last edited by Frinavale; Mar 31 '09, 02:02 PM. Reason: Added [code] tags. Please post code in [code] [/code] tags.
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2
    try smtp.Port = 25; (pop 110), this is usual but it could be different. One of my private mail has customer smtp port. Find out from your mail provider .

    here is the source: http://www.aspsnippets.com/post/2009...ng-CSharp.aspx

    ASPSnippets: An ASP.Net Tutorials Website, Author: Mudassar Khan, Tutorial Topics: ASP.Net, SQL Server, Windows, C#, VB.Net, AJAX, jQuery, AngularJS, MVC, JSON, FaceBook, Twitter, Google Plus, Google Maps, Windows, SSRS Reports, RDLC Reports, Crystal Reports, XML, HTML, HTML5, Charts.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      In order to send emails using gmail you need to provide credentials.
      Check out this quick reference on how to send emails using .net for more information.

      -Frinny

      Comment

      Working...