Results 1 to 5 of 5

Thread: send email from an .aspx page

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    send email from an .aspx page

    how do i write some codes to send email from
    an .aspx page? thanks.

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: send email from an .aspx page

    Code:
    MailMessage mail = new MailMessage();
    mail.From = "[email protected]";
    mail.To = "[email protected]";
    mail.Subject = "This is the subject";
    mail.Body = "This is the message";
        
    SmtpMail.SmtpServer = "localhost";
    SmtpMail.Send(mail);
    You need to reference the System.Web.Mail namespace for that to work. Also you need to check which SMTP server you can use to send the message (in most cases it is localhost though).

    This might help too -> http://www.aspheute.com/english/20000918.asp
    HTH

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  3. #3
    Lively Member zen_master's Avatar
    Join Date
    Apr 2005
    Location
    Buffalo, NY
    Posts
    114

    Re: send email from an .aspx page

    might need this too...interesting =)

  4. #4
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    Re: send email from an .aspx page

    Hellow,

    I'm looking for a way to mail in the background.. I tried this but it wont work.. Is there anything I maybe forgot?

    greetz

    nickname
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

  5. #5
    Member Nikhil Aggarwal's Avatar
    Join Date
    Jun 2005
    Location
    New Delhi, India
    Posts
    36

    Re: send email from an .aspx page

    You can check the following
    1) In the above code the SMTP server being used is "localhost".
    Code:
    SmtpMail.SmtpServer = "localhost";
    This means that the server hosting your ASP.Net application is itself the SMTP server. If this is not the case then replace "localhost" by the SMTP address or the IP address of the SMTP server to be used.

    2) Check to see what authentication method you are using for the application. It can be possible that the user may not be authenticated for the SMTP server. Add the following code to specify some more details before sending the mail.(This code is in c#)
    Code:
    //Set Mode to basic authentication
    Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");	
    //set your username here
    Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userName"); 
    //set your password here
    Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); 
    //set the SMTP server port number here. Default is 25
    Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
    Hope this helps.
    Nikhil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width