Sending email without using password in credentials

Hi everybody,

        The following code works perfectly as it sends information to the receiver's email address from the sender's(username) email address, but the problem i have is i must provide a password in the credentials in  order to send the email, if not i would get an error about authentication.
Is there any way i can send an email message from one email address to another one without providing the password and get no errors with authentication????

Dim smtp As SmtpClient
        Dim mailMsg As New MailMessage
        smtp = New SmtpClient("", 587)
        mailMsg = New MailMessage("", "", "Your enquiry has been confirmed", "Information was successfully sent to email")
         smtp.EnableSsl = True
        smtp.UseDefaultCredentials = False
        smtp.Credentials = New NetworkCredential("", "mypassword")         

Open in new window

Who is Participating?
lashler2Author Commented:
ok thanks everyone for the  help....I figured what i wanted to do wouldn't work unless i had my own IIS server so i could change the authenication settings. In response to RahulParashar, I tried using the line UseDefaultCredentials property as "True" before, but i just got the error message "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required".
You will have to change the authenication settings on the smtp service.
e.g. if you are running an smtp virtual server on windows server 2003.
Open up iis goto the properties of the smtp virtual server. Goto Access tab. click the Authentication button. Tick "Anonymous access".
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I don't think it is possible, unless you have your own IIS server, as stated by thePlonk.

Your code is using GMAIL smtp server and I don't think you have an access on that...
You can do so by making UseDefaultCredentials property "True" and not supplying credentials. so remove the line
(smtp.Credentials = .......)
and yes, you have to have your won exchange server for this.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.