Need help with CDOSYS script

Discussion in 'C#' started by zyberus, Jan 5, 2012.

  1. #1
    Here's the code that I have on the site:

                Set NewMailObj=Server.CreateObject("CDO.Message")
                Set objConfig = Server.CreateObject("CDO.Configuration")
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
                objConfig.Fields.Update
                Set NewMailObj.Configuration = objConfig
                NewMailObj.From = "Contact_Us@domain.com.my"
                NewMailObj.To = "info@domain.com.my"
                NewMailObj.Subject = "Enquiry from "& sname 
                NewMailObj.TextBody = "NAME: " & sname & vbCrLF & vbCrLF & "Subject: " & subject & vbCrLF & vbCrLF & "Email: " & email & vbCrLF & vbCrLF & "Message: " &  vbCrLF & Message 
    
                'NewMailObj.Send
               on error resume next
                   NewMailObj.Send
                  if Err.Number <> 0 then
                 response.Write "Email send failed: " & Err.Description & ".<br />"&vbcrlf
                  end if
    Code (markup):
    The thing is, my company is using google apps to host our webmail service. But our web-hosting server has it's own webmail as well. When this code is activated, the system seem to search for the recipient email in the web-host server instead of sending it to out google mail app account, which returns a 550 user not found error.

    Can someone tell me what I need to do to get it to send the email to our google mail app account instead of the web-hosting server?
     
    zyberus, Jan 5, 2012 IP
  2. slawek

    slawek Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this code:

    
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =  465
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =  1
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "account@gmail.com"
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "gmail password"
                objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") =1
                objConfig.Fields.Update
                Set NewMailObj.Configuration = objConfig
                NewMailObj.From = "Contact_Us@domain.com.my"
                NewMailObj.To = "info@domain.com.my"
                ...............................
    
    Code (markup):
    Regards.
    Slawek
     
    slawek, Jan 8, 2012 IP