473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using Authentication for sending Mail in VB2005

smahdis
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
1 1082
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

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

Similar topics

2
by: | last post by:
I am trying to use the mail function to send email. My ISP requires authentication. What do I need to add to the mail function to make it work? mail($to, $subject, $msg, $mailheaders); Thank...
3
by: HoustonComputerGuy | last post by:
I am working on getting my web applications moved to .Net 2.0 and am having some problems with System.Net.Mail. I get the following error when sending the mail: System.Net.Mail.SmtpException was...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.