Help!!! Send Email with Authentication

Hi. I need help!!!

I'm trying to send a email with smpt basic authentication (username and password) with Visual Basic 2005... but...!i can't!

Can anyone please help me

I need to use ICredentialsByHost

Thanks a lot and sorry if my english is not very good!



Answer this question

Help!!! Send Email with Authentication

  • Pockey

    Hi again.

    I can't send a email with authentication. :( 

    I allways get the same error.


    System.Net.Mail.SmtpException was caught
      Message="Failure sending mail."
      Source="System"
      StackTrace:
           at System.Net.Mail.SmtpClient.Send(MailMessage message)

           at System.Net.Mail.SmtpClient.Send(String from, String recipients, String subject, String body)

           at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e)

     


    ComponentModel.Win32Exception
    {"El simbolo proporcionado a la funcion no es valido"}
    {System.Collections.ListDictionaryInternal}

    Where is the problem.

    I use the same code of Joe_MS.

    Thanks!!!

  • Trini_Pierre

    RSantana wrote:
    anybody have any solution I'm having the same problem. Thanks

    well what problem are you having Take a look at this in the meantime:

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=928163&SiteID=1



  • jaggex

    Any help

    I try a lot of things... but don't work. With email servers that don't require authentication all work fine... but... when i need to send the username and password... error. :(

    Thanks again (and sorry if my english is not very good)

  • Kline Chen China

    anybody have any solution I'm having the same problem. Thanks

  • MariaMM

    Hi again. Thanks for the response... but don't work for me.

    I get this error: "Failure Sending Mail".

    If i send the email "FROM" and "TO" the same email address i can send the email ok... but if i select the "TO" from another domain i get this error.

    Sorry if my english is not very good!





  • Sam Vella

    Just want to thank you man. It works very good.

  • M. U.

    I hope this code will help you / Espero que os ayude:

            Dim clsMail As New System.Net.Mail.MailMessage
            Dim clsCliente As New System.Net.Mail.SmtpClient
            Dim clsDireccion As MailAddress
            Dim objCredencial As New System.Net.NetworkCredential

            ' Datos de configuracion de la cuenta
            objCredencial.UserName = "user"
            objCredencial.Password = "pass"

            ' Direccion que envia el correo
            clsDireccion = New MailAddress("user@domain.com", "Name")

            ' Creamos el mensaje a enviar / Configuring Message 
            clsMail.To.Add("user@anotherdomain.es")
            clsMail.Subject = "Pruebas"
            clsMail.From = clsDireccion
            clsMail.Body = "Este es un mail de prueba"

            '' Conexion al servidor SMTP / Connection to SMTP server
            clsCliente.Host = "server.domain.es"
            clsCliente.Credentials = objCredencial

            '' Envio del mail / Send mail
            clsCliente.Send(clsMail)

            MsgBox("Enviado")

     


  • lleoneye

    Maybe this will help someone. I had the same problem with Kerio mail server and this fixed it. It was the UseDefaultCredentials property that fixed it for me.

    mySMTP.UseDefaultCredentials = False

    mySMTP.Credentials = New Net.NetworkCredential("username", "password")


  • TELII

    Any help with this error

    My email server is KERIO MAIL SERVER and i don't have problem with Outlook, Eudora or other email clients.

    Thanks !

  • Terotech.Com Ltd

    Hi!

    There are some new APIs in the .NET Framework 2.0 that provide the functionality you're looking for.  If you need to pass a username and password, you're correct--an implementation of ICredentialByHost is required.  Here's a quick sample that might help you out:

    Imports System.Net.Mail
    Public
    Sub SendMail()
       Dim hostName As String = "[Insert URL Here]"   
       
    Dim mailWriter As New SmtpClient(hostName) 
       'NetworkCredential provides a basic implementation of ICredntials 
       
    'and ICredentialsByHost that can be used to perform password authentication.
       mailWriter.Credentials =
    New NetworkCredential("username", "password")
       mailWriter.Send(
    "From@Address.Com", "To@Address.Com", "Sample Subject", "Body of message goes here.")
    End Sub

    Hope this helps!

    Joe Binder
    The VB Team


  • abi

    I have exactly the same problem. I am using C# with ASP.NET 2.0 (VS 2005 RC1) and when I call smptclient.Send(msg) I get "Failure Sending Mail" and that is it. Any help will be greatly appreciated. Nobody has solved this issue yet in any of the postings I have found here and in Google.
    Tongue Tied

    If I copy / paste the code into VS 2003 with .Net 1.1 everything works great.

    thank you!!

  • tlc660

    Hi again!

    I get this error in the "ex.InnerException.Message"

    The error description is in Spanish...: "El simbolo proporcionado a la funcion no es valido"

    The english translation... "The symbol provided to the function is not valid"

    And in the ex.Message i get: "Failure sending mail."

    Thanks again!!!

    PD: The complete error (ex.InnerException.toString)
    System.ComponentModel.Win32Exception: El simbolo proporcionado a la funcion no es valido
       at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, Int32& statusCode)
       at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
       at System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie)
       at System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie)
       at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
       at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
       at System.Net.Mail.SmtpClient.GetConnection()
       at System.Net.Mail.SmtpClient.Send(MailMessage message)





  • AlexCr

    Bummer!

    In order to get a better idea of why this is failing, I'll need a bit more information about the error you're receiving.  Can you give the contents of the "Message" and "StackTrace" of the InnerException.  The InnerException is a property of the exception you're receiving, and it typically has considerably more detail than the outer exception.

    Thanks.

    Joe

  • Help!!! Send Email with Authentication