By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,377 Members | 3,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,377 IT Pros & Developers. It's quick & easy.

Using Authentication for sending Mail in VB2005

smahdis
P: 2
Hello Friends,
I am new to this Forum. Let me ask my question straightly
I faced a problem in vb 2005 and that is: I want to send Email using System.net.mail but I couldn't find anything about Authentication there.

Can you please give me a simple code for sending an email using SMTP and Authentication in VB 2005 (.net2)?!
May 2 '07 #1
Share this Question
Share on Google+
1 Reply


smahdis
P: 2
I finally found the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         Try
  3.             Dim strAddress As String = "xxx@xxxx.com"
  4.             Dim sm As New SmtpClient(Host, Port)
  5.             With sm
  6.                 .EnableSsl = True
  7.                 .Credentials = New NetworkCredential("MyuserName", "MyPass")
  8.                 .TimeOut = 20000       ' I add this extra line
  9.             End With 
  10.             Dim _from As MailAddress = New MailAddress(strAddress)
  11.             Dim _to As MailAddress = New MailAddress(strAddress)
  12.             Dim mMsg As New MailMessage(_from, _to)
  13.             mMsg.Subject = "Happy AAA"
  14.  
  15.             sm.Send(mMsg)
  16.  
  17.             msg = "Seccess!"
  18.  
  19.         Catch ex As Exception
  20.             msgbox (ex.Message)
  21.         End Try
  22.  
  23.  
May 2 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.