Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Sending Mail In Vb.net
Jimmy89
post Dec 3 2007, 12:44 AM
Post #1


Living at the Datacenter
Group Icon

Group: [HOSTED]
Posts: 696
Joined: 30-June 06
From: Australia
Member No.: 14,219



Hi,
I am trying to allow my program to send emails via a smtp server. Everything seems to be working the only problem is that i get an error response from the server saying
QUOTE
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication required


The Code that I am using is
CODE
Private Sub SendMail()
        Dim fromAddress As New MailAddress("from@mail.com", "Support")
        Dim toAddress As New MailAddress(txtEmail.Text, "User")
        Dim msg As New MailMessage(fromAddress, toAddress)

        msg.Body = My.Application.Info.DirectoryPath + "\support\mailtemplate.html"
        msg.Subject = "Support Ticket"
        msg.IsBodyHtml = True

        Dim mailSender As New System.Net.Mail.SmtpClient()
        mailSender.Host = "mail.myserver.com"
        mailSender.Port = 587
        Try
            mailSender.Send(msg)
            MsgBox("Message sent")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
End Sub


All I think I have to do is set up authentication for the server, but im not sure how to do that!
Thanks,
-jimmy

This post has been edited by Jimmy89: Dec 3 2007, 12:45 AM
Go to the top of the page
 
+Quote Post
faulty.lee
post Dec 4 2007, 04:20 PM
Post #2


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



Ya, most SMTP server now require authentication to send email, as a spam prevention feature, but i still receive as much spam or even more nowadays tongue.gif

Try add these code
CODE
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here


I copied the 3 lines of code from http://www.systemwebmail.com/faq/3.8.aspx

I haven't got time to test it out. Give it a try and post the result here.

Good Luck

Go to the top of the page
 
+Quote Post
Jimmy89
post Dec 5 2007, 06:24 AM
Post #3


Living at the Datacenter
Group Icon

Group: [HOSTED]
Posts: 696
Joined: 30-June 06
From: Australia
Member No.: 14,219



I seem to be getting my fair share of spam also, your not alone! tongue.gif

I went to the website and found that if I'm using .net 2 (which I am) I can use different code.

CODE
Sub Authenticate()
        'create the mail message
        Dim mail As New Net.Mail.MailMessage()

        'set the addresses
        mail.From = New Net.Mail.MailAddress("me@mycompany.com")
        mail.To.Add("you@yourcompany.com")

        'set the content
        mail.Subject = "This is an email"
        mail.Body = "this is the body content of the email."

        'send the message
        Dim smtp As New Net.Mail.SmtpClient("127.0.0.1")

        'to authenticate we set the username and password properites on the SmtpClient
        smtp.Credentials = New Net.NetworkCredential("username", "secret")
        smtp.Send(mail)
    End Sub 'Authenticate


This was from: http://www.systemnetmail.com/faq/4.2.aspx

yet this still returns the same error!

QUOTE
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication required
EDIT: I attempted using my astahost smtp details and now get a Failure Sending Mail error. The Inner Exception is
QUOTE
Unable to read data from the transport connection: net_io_connectionclosed.


This post has been edited by Jimmy89: Dec 5 2007, 06:47 AM
Go to the top of the page
 
+Quote Post
faulty.lee
post Dec 5 2007, 07:00 AM
Post #4


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



You can try sending through a working SMTP server, say, your existing SMTP server for your normal email provider. That way, you can eliminate the problem which might be caused by the server itself
Go to the top of the page
 
+Quote Post
Jimmy89
post Dec 5 2007, 12:32 PM
Post #5


Living at the Datacenter
Group Icon

Group: [HOSTED]
Posts: 696
Joined: 30-June 06
From: Australia
Member No.: 14,219



faulty, that should have been my first thought! it worked! which leads me to wonder why its not working with AstaHost? It must be something to do with the server and the way mail is setup through CPanel.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Sending message through Lan(7)
  2. THE BULK MAIL(6)
  3. Webmail On My Site(4)
  4. Get A G-mail Account!(68)
  5. E-mail Marketing :: Some Fundamentals(5)
  6. Send Mail Through Outlook Express(7)
  7. Mail Is No Longer Working?(10)
  8. Changed Domain Name, My Web-mail Gives A 550 Error(1)
  9. Failed Sending Email :: PHP ::(8)
  10. Need Help In Developing Internet Application Suite(9)
  11. You Wanna Get An Extra Yahoo Mail Adress In The Same Box(4)
  12. Using The Php Mail() Function For Images Or Attachments(3)
  13. Php Send Mail Through Smtp(8)
  14. PHP Mail Sending Is Not Working After cPanel Upgradation!(22)
  15. PHP: Need Help Sending Mail Using SMTP(5)
  1. Yahoo Mail With Yahoo Chat(7)
  2. Apparently Unlimited Means None(12)
  3. Messenger Mail Bug?(2)
  4. Mail(3)
  5. How Do You Set Up A Domain E-Mail Address?(6)
  6. Sending E-mail Alert Through Sms(3)
  7. Filtering Out Unwanted Junk Mail Using Regular Expression.(0)
  8. Who Uses A Yahoo E-mail(8)
  9. Htl Mail(0)
  10. Preventing Spam When Using Php's Mail Function(6)
  11. Mail Servers?(3)
  12. E-mail - Firefox(6)
  13. Outlook Express: Older Sent Mail Disappears(1)


 



- Lo-Fi Version Time is now: 11th October 2008 - 06:28 AM