locked
email snippet "send" does not complete RRS feed

  • Question

  • Hello,

    I am trying to use the email "snippet". 

    First I found that the snippet is not compete.  It did not include code to send the network credentials (username and password) to the email server.  Even with that code added, when I send an email, the program hangs and never returns an error.

    Here is the code.  Thanks for any suggestions!

    Dim server As SmtpClient = New SmtpClient("mail.myserver.com")
    server.Credentials =
    New Net.NetworkCredential("username", "password")
    Dim email As MailMessage = New MailMessage()
    email.IsBodyHtml =
    False
    email.From = New MailAddress("myemail@myserver.com")
    email.To.Add("
    myemail@myserver.com")
    email.Subject =
    "subject"
    email.Body = "this is my email message"
    '
    Try
      
    server.Send(email)

    Catch ex As SmtpFailedRecipientException
          Msgbox(
    "error: " & ex.Message & "\nFailing recipient: " & ex.FailedRecipient)

    End Try

    Saturday, November 26, 2005 1:22 AM

Answers

  • It is probably hanging looking for the server!  Replace mail.Myserver.com with a valid smtp server name and try again!
    Thursday, July 6, 2006 1:38 PM

All replies

  • It is probably hanging looking for the server!  Replace mail.Myserver.com with a valid smtp server name and try again!
    Thursday, July 6, 2006 1:38 PM
  • I am using and SMTP relay program on my machine "Free SMTP Server".  I am using the following code to try and send an e-mail from my program per your example:

    'Create a new MailMessage object and specify the"From" and "To" addresses

    Dim Email As New System.Net.Mail.MailMessage("myEmail@gmail.com", "myEmail@gmail.com")

    Email.Subject = "test subject"

    Email.Body = "this is a test"

    Dim mailClient As New System.Net.Mail.SmtpClient()

    'This object stores the authentication values

    Dim basicAuthenticationInfo As _

    New System.Net.NetworkCredential("myUserName", "myPassword")

    'Put your own, or your ISPs, mail server name onthis next line

    mailClient.Host = "localhost"

    mailClient.UseDefaultCredentials = False

    mailClient.Credentials = basicAuthenticationInfo

    mailClient.Send(Email)

     

    where I actually use my UserName and Password etc in the code.

     

    It appears to work (no error messages) but I never recieve the email.  I am obviously using Gmail and this works with mail routines.

    Can this be a security issue?  I tried to enable SSL, but get an error that server doesn't support it.  Perhaps blocked by Reverse DNS lookup?

    Any ideas are welcome!

     

    Saturday, August 12, 2006 12:44 AM