We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

newbie27
newbie27 asked
on
Medium Priority
530 Views
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?

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

Comment
Watch Question

Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Microsoft Dynamics CRM Consultant
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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
Rikin ShahMicrosoft Dynamics CRM Consultant
CERTIFIED EXPERT

Commented:
Change your port to 587 and try the same code.

http://mail.google.com/support/bin/answer.py?answer=13287

Author

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

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.