Cdo.message - not recieving any mail

Discussion in 'C#' started by akinak, Jun 9, 2008.

  1. #1
    I have this code below. I am not recieving any email in my inbox. When I checked I see that all are going to inetpub/mailroot/drop with the message that delivery failed.

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    
    
     <html>
     <body>
     <% dim firstname, lastname, email, confirmemail, msg, body, mail
     firstname=Request.Form("firstname")
       lastname=Request.Form("lastname")
       email=Request.Form("email")
       confirmemail=Request.Form("confirmemail")
       msg=Request.Form("msg")
       body=body & "First Name:"& firstname & VbCrLf 
      body=body & "Last Name:" & lastname & VbCrLf
      body=body & "Email:" & email & VbCrLf
      body=body & "Confirm Email:" & confirmemail & VbCrLf
      body=body & "Message:" & msg & VbCrLf
      Set mail= Server.CreateObject("CDO.Message")
      sch = "http://schemas.microsoft.com/cdo/configuration/"
    Set cdoConfig = CreateObject("CDO.Configuration")
    With cdoConfig.Fields
    .Item(sch & "smtpserver") = "localhost"
    .Item(sch & "smtpserverport") = 25
    .Item(sch & "sendusing") = 2 
    .Item(sch & "smtpconnectiontimeout") = 60
    .update
    End With
    
      mail.From= "USA"
      mail.To = "me@domain.com"
      mail.HTMLBody = body
      mail.Send
    Response.Write("Thank you" & firstName & " " & lastName & "for submitting the form." & VbCrLf &"We will contact you at" & email & "or" & contact &".")
    Set mail= nothing
    %>
    </body>
    </html>
    Code (markup):
    Also, Iam not sure what to put in here(Iam a newbie to asp):
    .Item(sch & "smtpserver") = "localhost"

    Plz help..
     
    akinak, Jun 9, 2008 IP
  2. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In .Item(sch & "smtpserver") = "localhost" the "localhost" should be replaces by the SMTP server of your web host. This normally takes the form of mail.yourhostsname.com but you need to check your hosts FAQs or contact their support to find the actual name. Also if you host required authenication on their SMTP server you will need to add in your SMTP username and password. Again here you should check with your webhost. Cheers.
     
    Jhar, Jun 10, 2008 IP
  3. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thnx :). I was just about to post the same thing..I resolved it..and you are right..this was the problem
     
    akinak, Jun 10, 2008 IP
  4. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #4
    You need to know the smtp server of the email server you use.
    for example for yahoo you should use:
    smtp.mail.yahoo.com (port 25)
    smtp.gmail.com (port 465)

    You can also use the SMTP mail server address provided by your local ISP.

    It usually is pretty same like the domain you use plus smtp ahead i.e. smtp.domain.com

    Regards :)
     
    yugolancer, Jun 10, 2008 IP
  5. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #5
    WOW how quick you were .. it took me only one minute to type that and meanwhile you have resolved the problem.
    Alright i am glad to got it solved. Cheers :)
     
    yugolancer, Jun 10, 2008 IP
  6. akinak

    akinak Peon

    Messages:
    256
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ha ha..I solved it first, then posted it. And no it didn't took me a minute, It actually took me quite a few hours. I posted this problem yesterday ;)
     
    akinak, Jun 10, 2008 IP
  7. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #7
    post #2 - Jhar: Today, 5:36 pm
    post #3 - akinak: Today, 5:38 pm
    post #4 - yugolancer: Today, 5:39 pm

    This what i am talking about lol

    However i am glad to hear that you have sorted the problem out.
     
    yugolancer, Jun 10, 2008 IP