• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 508
  • Last Modified:

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

0
newbie27
Asked:
newbie27
3 Solutions
 
prashanthdCommented:
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.
0
 
charlie324Commented:
Hi,
yes, even I tried using the script and it works OK for me.
are you using with your gmail account or another domain account?
0
 
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
change below and try-
oEmail.Configuration.Fields.Item(sSchema & "smtpusessl") = True
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
newbie27Author Commented:
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
0
 
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Change your port to 587 and try the same code.

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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now