Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GMail blues
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
GMail blues
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows NT
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01570810
Message ID:
01570810
Views:
71
This code works on all the sites where I have installed it, except in some. The client.send() just fails. I guess this is firewall issue. I there anyway one can figure out why the client.send fails?

Thanks (Sergey :) ).
    Public Sub SendEmail(ByVal subject As String, ByVal messageBody As String, _
     ByVal fromAddress As String, ByVal toAddress As String, ByVal ccAddress As String)

        Dim message As New MailMessage()
        Dim client As New SmtpClient()

        'Set the sender's address
        message.From = New MailAddress(fromAddress)
        'Allow multiple "To" addresses to be separated by a semi-colon
        If (toAddress.Trim.Length > 0) Then
            For Each addr As String In toAddress.Split(";"c)
                message.To.Add(New MailAddress(addr))
            Next
        End If

        'Allow multiple "Cc" addresses to be separated by a semi-colon
        If (ccAddress.Trim.Length > 0) Then
            For Each addr As String In ccAddress.Split(";"c)
                message.CC.Add(New MailAddress(addr))
            Next
        End If
        'Set the subject and message body text
        message.Subject = subject
        message.IsBodyHtml = False
        message.Body = messageBody

        client.Host = "smtp.gMAIL.com"
        client.Credentials = New System.Net.NetworkCredential("***@gmail.com", "***")
        'client.Port = 587
        client.Port = 465
        client.EnableSsl = True
        'Send the e-mail message
        Dim l As Boolean = False
        Try
            client.Send(message)
        Catch
            l = True
        End Try
        If l Then
            MsgBox("Send failure")
        Else
            MsgBox("OK")
        End If
    End Sub

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Next
Reply
Map
View

Click here to load this message in the networking platform