smtp from vb.net console application on pc

Discussion in 'Email' started by dave123, Mar 26, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have a vb.net console application I am building with vs 2008 and I cannot get it to send email.

    If I send to an email that is on my domain then it sends ok, but if I send to hotmail or any other email it throws an error.

    My pc is xp.

    I have read all day on google about similar problems people have when sending from their website and obviously they need to use localhost, but that will not fix my problem.

    Thanks for any help. I really need this to work.

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Imports System.Net.Mail

    Module test_email
    Public Function send_email()
    Try
    Dim Message As MailMessage = New MailMessage()
    Dim Smtp As New SmtpClient()
    Dim SmtpUser As New System.Net.NetworkCredential()
    Message.From = New MailAddress("[email protected]")
    Message.To.Add(New MailAddress("[email protected]"))
    Message.IsBodyHtml = False
    Message.Subject = "3 new, 1 price update"
    Message.Body = "this is a test"
    SmtpUser.UserName = "[email protected]"
    SmtpUser.Password = "password"
    SmtpUser.Domain = "mydomain.com"
    Message.Priority = MailPriority.Normal
    Smtp.UseDefaultCredentials = False
    Smtp.Credentials = SmtpUser
    Smtp.Host = "smtp.mydomain.com"
    Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
    Smtp.Port = 587
    Smtp.Send(Message)
    Catch ex As SmtpFailedRecipientException
    LogErrors.WriteError(ex.Message)
    Return "fail"
    Exit Function
    End Try
    Return "success"
    End Function
    End Module
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    exception returned:

    Mailbox unavailable. The server response was: <[email protected]> No such user here
     
  2. This is the exception that comes back:
    ----------------------------------------------------------------------
    Mailbox unavailable. The server response was: <[email protected]> No such user here
    ---------------------------------------------------------------------
    [email protected] is the address I am sending to...

    The funny thing is, that if I send to an email address that is a valid pop3 account on the domain I am sending from, it will send.

    However, I need to be able to send email to any email address.

    Because I am authenticating the account sending the email, it should work.

    Thanks again for anything. I really need this to work.
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    This behavior usually means that you are not submitting the SMTP authentication information with your application.

    In our mail server setup, you can relay to your own domain without authentication but it will return an error when you try to send to a domain outside of the server.
     
  4. What other authenticating do I have to do beside this:

    SmtpUser.UserName = "[email protected]"
    SmtpUser.Password = "password"
    SmtpUser.Domain = "mydomain.com"


    My application is shown in its entirety above.
     
  5. woo hoo!

    I finally found the right way to do it. This is working right now, although I have no idea why!

    Thanks!

    Dim Message As MailMessage = New MailMessage()
    Dim Smtp As New SmtpClient()
    Dim SmtpUser As New System.Net.NetworkCredential("[email protected]", "password")

    Message.From = New MailAddress("[email protected]")
    Message.To.Add(New MailAddress("[email protected]"))
    Message.IsBodyHtml = False
    Message.Subject = "Another test"
    Message.Body = "This is a test"
    Message.Priority = MailPriority.Normal
    Smtp.EnableSsl = False

    Smtp.Credentials = SmtpUser
    Smtp.Host = "smtp.mydomain.com"
    Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
    Smtp.Port = 587

    Smtp.Send(Message)
     
  6. Far Out Dude!

    :) ;) :D :cool: I just worked for about 2 hours trying to get this to work. Finally gave up and went looking for answers.

    Your solution worked for me!

    Thanks

    Volking
     
  7. I tried the solution given by Dave123 above with 2 differences
    1) My domain name and userid/password reflect my domain
    2) It was done in c#

    I have wraped the code in a try/catch/finally block and am not receiving any errors however I do not appear to get any mail sent... at least none is received.
    1) Is there a way to check to see if the messages are waiting for pickup?
    2 ) How do i debug an SMTP problem that doesn't give me any error messages?
     
  8. How are you passing the From and To address? If you are passing it as a variable, try hard coding the email address.
     
  9. I hard coded ALL message information and still no Cigar. No errors and no emails.
     
  10. What do you mean by....

    1) My domain name and userid/password reflect my domain

    What are the values you are inputting? If you are sending through our smtp server you need to input the full email address. Also make sure the smtp server you are using is properly resolving to our mail servers IP address.
     
  11. Post your code.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page