Showing posts with label objsmtpas. Show all posts
Showing posts with label objsmtpas. Show all posts

Monday, March 26, 2012

System.net.mail

Simple vb code, right?

Dim objSMTPAs New SmtpClient("mailserver.domain.com", 25)Dim objMsg asNew MailMessage("To@dotnet.itags.org.domain.com","from@dotnet.itags.org.domain.com","test","body testing")objSMTP.Send(objMsg)

When I run the above code, I get an authentication failure. I've tried using a non-default authentication like this:

Dim objMsgAs New MailMessage("from@dotnet.itags.org.domain.com","To@dotnet.itags.org.domain.com","Test","Body of message. Testing 1 2 3")Dim objSMTPAs New SmtpClient("mail.server.com") objSMTP.UseDefaultCredentials =False Dim objCredsAs New NetworkCredential objCreds.UserName ="username" objCreds.Password ="password" objSMTP.Credentials = objCreds objSMTP.Send(objMsg)
But I still get the same error. How do I give the mail server my username and password?

what about putting settings in the configuration file?

 <system.net><mailSettings> <smtp deliveryMethod="network"> <network host="mail.domain.com" userName="username OR DomainEmail" password="Password" defaultCredentials="true"/></smtp></mailSettings> </system.net>


have you tried like this ?

http://www.systemnetmail.com/faq/4.2.aspx

it's only slightly different

objSMTP.Credentials = New NetworkCredential("username", "secret")