HighTechTalks DotNet Forums  

SmtpClient authentication

VB.net microsoft.public.dotnet.languages.vb


Discuss SmtpClient authentication in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mickey
 
Posts: n/a

Default Re: SmtpClient authentication - 06-30-2010 , 11:15 PM






I tried that and it got me past the original problem but now it just fails
to send. Something about not being able to connect to the server. I was able
to ping the server so maybe I should try increasing the timeout.

Thanks
Mickey

"Onur Güzel" <kimiraikkonen85 (AT) gmail (DOT) com> wrote

On Jul 1, 7:01 pm, "mickey" <mickmarsh... (AT) earthlink (DOT) net> wrote:
Quote:
Hi
I'm trying to add simple email capability to a program I wrote but when I
send the mail the responce from the server indicates thet I need to use
authenticain.
I have no clue as to how to do that. Here is the code I'm using. Can
anyone
help please?

Thanks
Mickey

Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, _
ByVal strBody As String, ByVal strSMTPServer As String)
Dim FromAddress As New System.Net.Mail.MailAddress(strFrom)
Dim ToAddress As New System.Net.Mail.MailAddress(strTo)
'send the email
Try
Dim insMail As New MailMessage()
With insMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = strSubject
.Body = strBody
End With
Dim emailClient As New SmtpClient(strSMTPServer)
Try
emailClient.Send(insMail)
Catch ex As Exception
MsgBox(ex.Message)
End Try

Catch e As Exception
MsgBox(e.Message)
End Try

End Sub
You need to instantiate a NetworkCredential object like this:

Dim cred as New NetworkCredential _
(username, password)
emailClient.Credentials = cred

HTH,

Onur Güzel

Reply With Quote
  #2  
Old   
mickey
 
Posts: n/a

Default SmtpClient authentication - 07-01-2010 , 11:01 AM






Hi
I'm trying to add simple email capability to a program I wrote but when I
send the mail the responce from the server indicates thet I need to use
authenticain.
I have no clue as to how to do that. Here is the code I'm using. Can anyone
help please?

Thanks
Mickey

Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, _
ByVal strBody As String, ByVal strSMTPServer As String)
Dim FromAddress As New System.Net.Mail.MailAddress(strFrom)
Dim ToAddress As New System.Net.Mail.MailAddress(strTo)
'send the email
Try
Dim insMail As New MailMessage()
With insMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = strSubject
.Body = strBody
End With
Dim emailClient As New SmtpClient(strSMTPServer)
Try
emailClient.Send(insMail)
Catch ex As Exception
MsgBox(ex.Message)
End Try

Catch e As Exception
MsgBox(e.Message)
End Try

End Sub

Reply With Quote
  #3  
Old   
Onur Güzel
 
Posts: n/a

Default Re: SmtpClient authentication - 07-02-2010 , 01:38 AM



On Jul 1, 7:01*pm, "mickey" <mickmarsh... (AT) earthlink (DOT) net> wrote:
Quote:
Hi
I'm trying to add simple email capability to a program I wrote but when I
send the mail the responce from the server indicates thet I need to use
authenticain.
I have no clue as to how to do that. Here is the code I'm using. Can anyone
help please?

Thanks
Mickey

*Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, _
* * ByVal strBody As String, ByVal strSMTPServer As String)
* * * * Dim FromAddress As New System.Net.Mail.MailAddress(strFrom)
* * * * Dim ToAddress As New System.Net.Mail.MailAddress(strTo)
* * * * 'send the email
* * * * Try
* * * * * * Dim insMail As New MailMessage()
* * * * * * With insMail
* * * * * * * * .From = FromAddress
* * * * * * * * .To.Add(ToAddress)
* * * * * * * * .Subject = strSubject
* * * * * * * * .Body = strBody
* * * * * * End With
* * * * * * Dim emailClient As New SmtpClient(strSMTPServer)
* * * * * * Try
* * * * * * * * emailClient.Send(insMail)
* * * * * * Catch ex As Exception
* * * * * * * * MsgBox(ex.Message)
* * * * * * End Try

* * * * Catch e As Exception
* * * * * * MsgBox(e.Message)
* * * * End Try

* * End Sub
You need to instantiate a NetworkCredential object like this:

Dim cred as New NetworkCredential _
(username, password)
emailClient.Credentials = cred

HTH,

Onur Güzel

Reply With Quote
  #4  
Old   
Onur Güzel
 
Posts: n/a

Default Re: SmtpClient authentication - 07-03-2010 , 03:40 AM



On Jul 1, 7:15 am, "mickey" <mickmarsh... (AT) earthlink (DOT) net> wrote:
Quote:
I tried that and it got me past the original problem but now it just fails
to send. Something about not being able to connect to the server. I was able
to ping the server so maybe I should try increasing the timeout.

Thanks
Mickey

"Onur Güzel" <kimiraikkone... (AT) gmail (DOT) com> wrote in message

news:c39b9548-7f31-4ad8-9d5f-d548ea40606c (AT) j8g2000yqd (DOT) googlegroups.com...
On Jul 1, 7:01 pm, "mickey" <mickmarsh... (AT) earthlink (DOT) net> wrote:



Hi
I'm trying to add simple email capability to a program I wrote but whenI
send the mail the responce from the server indicates thet I need to use
authenticain.
I have no clue as to how to do that. Here is the code I'm using. Can
anyone
help please?

Thanks
Mickey

Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, _
ByVal strBody As String, ByVal strSMTPServer As String)
Dim FromAddress As New System.Net.Mail.MailAddress(strFrom)
Dim ToAddress As New System.Net.Mail.MailAddress(strTo)
'send the email
Try
Dim insMail As New MailMessage()
With insMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = strSubject
.Body = strBody
End With
Dim emailClient As New SmtpClient(strSMTPServer)
Try
emailClient.Send(insMail)
Catch ex As Exception
MsgBox(ex.Message)
End Try

Catch e As Exception
MsgBox(e.Message)
End Try

End Sub

You need to instantiate a NetworkCredential object like this:

Dim cred as New NetworkCredential _
(username, password)
emailClient.Credentials = cred

HTH,

Onur Güzel
Besides incresing timeout value, you can also think of enabling SSL by
means of EnableSSL property. The authentication is done with
NetworkCredential object. For more info, you need to read docs of SMTP
server provider if it's not yours.

HTH,

Onur Güzel

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.