ASP send email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • silvia21
    New Member
    • Jan 2008
    • 6

    ASP send email

    My OS is Windows XP. SMTP is not working. Virtual directory mail is coming. but mail is not going in smtp sever. i am using ASP & MS ACCESS. i have used one form. if i will click submit button that details r goto mail. plz help for this coding.
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Can you show the code you are using to send mail?

    Dr B

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Hello silvia21,

      Give this a try. It has some error trapping that hopefully will give you some meaningful errors if any come up.

      Hope this helps~

      [CODE=asp]
      <%
      Set myMail=CreateOb ject("CDO.Messa ge")
      myMail.Subject = "Hello"
      myMail.From = "Bob@bob.co m"
      myMail.To = "Sam@sam.co m"
      myMail.TextBody = "Your message to Sam."

      On Error Resume Next
      myMail.Send
      If Err <> 0 Then
      Response.Write( "Error occurred: " & Err.Description )
      else
      Response.Write( "Your message was sent successfully.")
      End If
      Response.End
      %>

      [/CODE]

      Comment

      • jawaharks
        New Member
        • Jan 2008
        • 12

        #4
        In c#,


        Add this namespaces

        using System.Web.Mail ;
        using System.Net.Mail ;


        now,

        SmtpClient objSmtpClient = new SmtpClient();
        objSmtpClient .Send(txtFromAd dress.Text, txtToAddress.te xt, txtSubject.Text , txtBody.Text);



        Before this you have to edit the web.config page in the system.net
        there u have to mention your mail domain name and the port number


        ex:
        <system.net>
        <mailSettings >
        <smtp>
        <network host="mail.XYZ. com" port="25" userName="Anyna me" password="asdkf hfffasf"/>
        </smtp>
        </mailSettings>
        </system.net>

        Comment

        • gotonagle
          New Member
          • Nov 2007
          • 19

          #5
          for more knowledge go through these once ...............
          Code:
          Sending a text e-mail:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.TextBody="This is a message."
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending a text e-mail with Bcc and CC fields:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.Bcc="someoneelse@somedomain.com"
          myMail.Cc="someoneelse2@somedomain.com"
          myMail.TextBody="This is a message."
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending an HTML e-mail:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.HTMLBody = "<h1>This is a message.</h1>" 
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending an HTML e-mail that sends a webpage from a website:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" 
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending an HTML e-mail that sends a webpage from a file on your computer:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm" 
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending a text e-mail with an Attachment:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.TextBody="This is a message."
          myMail.AddAttachment "c:\mydocuments\test.txt"
          myMail.Send
          set myMail=nothing
          %> 
          
          Sending a text e-mail using a remote server:
          
          <%
          Set myMail=CreateObject("CDO.Message")
          myMail.Subject="Sending email with CDO"
          myMail.From="mymail@mydomain.com"
          myMail.To="someone@somedomain.com"
          myMail.TextBody="This is a message."
          myMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
          'Name or IP of remote SMTP server
          myMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
          ="smtp.server.com"
          'Server port
          myMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
          =25 
          myMail.Configuration.Fields.Update
          myMail.Send
          set myMail=nothing
          %>
          Hoping it would be helpful.
          Thanks
          Rahul.

          Comment

          • silvia21
            New Member
            • Jan 2008
            • 6

            #6
            hi thank u. i got the mail. first i used

            Set sm = Server.CreateOb ject("CDONTS.Ne wMail")

            that only error.

            thank u.

            Comment

            • silvia21
              New Member
              • Jan 2008
              • 6

              #7
              hi thank u. i got the mail. first i used

              Set sm = Server.CreateOb ject("CDONTS.Ne wMail")

              that only error.

              thank u.

              Comment

              Working...