the message cannot be sent to the smtp server. the transport error was xxxxxx. the server response was not available

Posted on 2011-04-28
Last Modified: 2012-05-11
Hello Experts
I am trying the simple vbscript to send emails from the server without SMTP service, we had STMP service on this server earlier but now we have migrated to google apps for email service.
No emails are going out from the server now which was using old server details, I am trying to test with simple script to see if I can send any email using gmail acnt details but having no luck yet ..
I am now getting the following error message when I use the attached script to send a test email

>>the message cannot be sent to the smtp server. the transport error was xxxxxx. the server response was not available

Please can someone advise?


Sub SendEmailGMail(sSubject, sEmailText, sGmailEmailAddress, sGmailPassword, sTo)
    Set oEmail = CreateObject("CDO.Message")
    oEmail.From = sGmailEmailAddress
    oEmail.To = sTo

    oEmail.Subject = sSubject
    oEmail.HTMLbody = sEmailText

    sSchema = ""
    oEmail.Configuration.Fields.Item(sSchema & "sendusing") = 2
    oEmail.Configuration.Fields.Item(sSchema & "smtpserver") = ""
    oEmail.Configuration.Fields.Item(sSchema & "smtpserverport") = 465
    oEmail.Configuration.Fields.Item(sSchema & "smtpauthenticate") = 1
    oEmail.Configuration.Fields.Item(sSchema & "sendusername") = sGmailEmailAddress
    oEmail.Configuration.Fields.Item(sSchema & "sendpassword") = sGmailPassword
    oEmail.Configuration.Fields.Item(sSchema & "smtpusessl") = 1
    oEmail.Configuration.Fields.Item(sSchema & "smtpconnectiontimeout") = 60

    Set oEmail = Nothing
End Sub

Open in new window

Question by:newbie27
    LVL 12

    Assisted Solution

    I have tested the code and works fine...

    When I gave wrong user name or password I get the above error, so check your credentials and try again.
    LVL 6

    Assisted Solution

    yes, even I tried using the script and it works OK for me.
    are you using with your gmail account or another domain account?
    LVL 19

    Accepted Solution

    change below and try-
    oEmail.Configuration.Fields.Item(sSchema & "smtpusessl") = True
    LVL 8

    Author Comment

    Hello Folks,

    Thanks for your input.


    You caught me there, if I use the gmail email account to send email then its working ok.
    However, when I use the company domain which is now managed via google apps, its not working with the email address.

    The domain is now hosted on Gmail servers, however the email address still show as  instead of

    I am using gmail service using their web interface to send and recieve emails using and it works to send and recieve, however, when i use the same account on the web server in my  test script, its failing.

    Can someone advise how can I go about fixing this?

    Can I use different from address in the script?

    Please advise

    LVL 19

    Expert Comment

    by:Rikin Shah
    Change your port to 587 and try the same code.
    LVL 8

    Author Comment

    thanks folks it looks like, its working OK now. Please can someone advise what change do I need in the following code?

    Public Shared Function SendEmail(ByVal From As String, ByVal ToField As String, ByVal Subject As String, ByVal Body As String, ByVal Attachment As Collection) As Boolean
            Dim Email As System.Net.Mail.MailMessage
            Dim MailServer As New System.Net.Mail.SmtpClient
            Dim MailServerAddress As String = ConfigurationManager.AppSettings("MailServer")
            Dim AdminEmail As String = ConfigurationManager.AppSettings("AdminEmailAddress")
                Email = New System.Net.Mail.MailMessage(From, ToField, Subject, Body)
                Email.From = New System.Net.Mail.MailAddress(From, "Customer Service")
                For i As Integer = 1 To Attachment.Count
                    Email.Attachments.Add(New System.Net.Mail.Attachment(Attachment(i)))
                MailServer = New System.Net.Mail.SmtpClient(MailServerAddress)
                MailServer.Credentials = New Net.NetworkCredential("websitesender", "xCvfKa!")
            Catch ex As Exception
                MailServer = New System.Net.Mail.SmtpClient(MailServerAddress)
                MailServer.Credentials = New Net.NetworkCredential("websitesender", "xCvfKa!")
                MailServer.Send(AdminEmail, AdminEmail, "Web Site SendEmail error", "From: " & From & ", To: " & ToField & "Subject: " & Subject & ex.ToString)
                Return False
            End Try
            Return True
        End Function

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
    This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now