Jump to content

Enviar E-Mails para vários servidores em simultâneo (Ex. Hotmail, GMail,Etc)


TiagoCruz
 Share

Recommended Posts

Dim client As New  SmtpClient()
            With client
                .Credentials = networkCredentials
                .Host = "smtp.gmail.com"
                .EnableSsl = True

                .Send(message1)
            End With

Então aqui tenho que fazer um If e colocar os seguintes servidores que quiser utilizar?

Link to comment
Share on other sites

Existem várias maneiras de fazer isso...

A mais simples, imaginando que tu tens os emails numa lista, ao correres a lista verificas qual o host...

 Dim client As New SmtpClient()
        If emailDestino.ToLower.Contains("@gmail.") Then
            With client
                .Credentials = networkCredentials
                .Host = "smtp.gmail.com"
                .EnableSsl = True
            End With
        ElseIf emailDestino.ToLower.Contains("@hotmail.") Then
            With client
                .Credentials = networkCredentials
                .Host = "smtp.hotmail.com"
                .EnableSsl = True
            End With
        End If

Isto pode e deve ser optimizado...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.