Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

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

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?

Thanks


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 = "http://schemas.microsoft.com/cdo/configuration/"
    oEmail.Configuration.Fields.Item(sSchema & "sendusing") = 2
    oEmail.Configuration.Fields.Item(sSchema & "smtpserver") = "smtp.gmail.com"
    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
    oEmail.Configuration.Fields.Update
    oEmail.Send

    Set oEmail = Nothing
End Sub

Open in new window

SOLUTION
Avatar of prashanthd
prashanthd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of newbie27

ASKER

Hello Folks,

Thanks for your input.

Chalie324,

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 xyz.com is now hosted on Gmail servers, however the email address still show as admin@xyx.com  instead of admin@gmail.com

I am using gmail service using their web interface to send and recieve emails using admin@xyz.com 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

Thanks
Change your port to 587 and try the same code.

http://mail.google.com/support/bin/answer.py?answer=13287
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")

        Try

            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)))
            Next
            MailServer = New System.Net.Mail.SmtpClient(MailServerAddress)
            MailServer.Credentials = New Net.NetworkCredential("websitesender", "xCvfKa!")
            MailServer.Send(Email)

        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