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!

Help!!! Send Email with Authentication
Pockey
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
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
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
MariaMM
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
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 =
FalsemySMTP.Credentials =
New Net.NetworkCredential("username", "password")TELII
My email server is KERIO MAIL SERVER and i don't have problem with Outlook, Eudora or other email clients.
Thanks !
Terotech.Com Ltd
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.MailPublic 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
If I copy / paste the code into VS 2003 with .Net 1.1 everything works great.
thank you!!
tlc660
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)
AlexCr
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