are there any examples i can follow?

I have created a form in vb.net, where the user supplies thier name, thier
email address, and thier comments. I want to create an email message and send
the information the user supplies to me when the user clicks the submit
button on the VB form. How do I do this, making the process as automated for
the user as possible Are there examples somewhere that I can study


Answer this question

are there any examples i can follow?

  • Arkman5

    Your user needs to provide a mail server to use, otherwise the rest can be done entirely in code.  The URL below goes to a page with an example

    http://www.freevbcode.com/ShowCode.asp ID=6401

  • Melapower3000

    I have no idea, I don't use yahoo mail.  Why don't you go to their website and find out That's assuming they offer an SMTP server.  A free mail site is unlikely to offer this, your ISP is the one who should offer you use of an SMTP server.

    Much as I prefer to encourage people to look stuff up for themselves, I looked it up for you:

    smtp.mail.yahoo.com

    Of course, you need to provide a valid username/password to validate your right to use the server, or it will fail.




  • Vadmyst

    Use the mail server that your ISP provides, instead of the yahoo one.

  • PhilJComputerGuy

    I have a valid username/password. Im not sure how to specify that programmatically. Would that be in the headers of the email message or somewhere else

    I have not found an example where a userName/Password is specified

    Thanks
    Shawn

  • TheMasterofHitenMitsurugi

    so what should i do
  • seva0412

    i have specified the username/password but i am getting the following error codes

    the error mesage:
    System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

      --- End of inner exception stack trace ---
      at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
      at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
      at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
      at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args)
      at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
      --- End of inner exception stack trace ---
      at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
      at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
      at System.Web.Mail.SmtpMail.Send(MailMessage message)
      at Horizons_Without_Boundries.FrmFeedBack.SubmitButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\Owner\My Documents\Visual Studio Projects\Horizons Without Boundries\Form5.vb:line 122

    the code to the button click :

    Private Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton.Click

        Dim email As New System.Web.Mail.MailMessage
        

        Try
          email.To = "mcsdhunter@yahoo.com"
          email.Priority = Web.Mail.MailPriority.Normal
          email.From = "mcsdhunter@yahoo.com"
          email.Body = Me.RichTextBox1.Text

          email.Subject = "Application Issue"
          email.BodyFormat = Web.Mail.MailFormat.Text
          email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
          email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userid") 'your username goes here
          email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password") 'your password goes here

          System.Web.Mail.SmtpMail.SmtpServer = "smtp.mail.yahoo.com"
          System.Web.Mail.SmtpMail.Send(email)
          MsgBox("email sent successfully", MsgBoxStyle.Information)

        Catch ex As System.Web.HttpException
          RichTextBox1.Text = ex.ToString

        Finally
          
        End Try



      End Sub


  • - Pascal -

    Hmm... you're right.  Your mail server with yahoo is going to require one, I am sure, but you're right that I can't see anywhere that you can specify them.  Generally an ISP requires a username/password only if you're not logged in to the web using that ISP, it's only webmail that will have the issue.


  • bool007

    my isp is roadrunner and requires a password as well
  • James K

    well, all i want from the user is thier comments. the email information can be hard coded much like the sample I have below. I think I have the stmp server value wrong, but im not sure what it is. How do I find the correct stmp server

    Private Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton.Click

    Dim email As New System.Web.Mail.MailMessage

    Try

    email.To = "mcsdhunter@yahoo.com"

    email.From = "mcsdhunter@yahoo.com"

    email.Body = Me.RichTextBox1.Text

    email.Subject = "Application Issue"

    email.BodyFormat = Web.Mail.MailFormat.Text

    System.Web.Mail.SmtpMail.SmtpServer = "http://us.f329.mail.yahoo.com"

    System.Web.Mail.SmtpMail.Send(email)

    Catch ex As System.Web.HttpException

    MsgBox(ex.ToString)

    End Try

     

     

    End Sub

     

  • MarkShep

    the code im trying to write will email a message from my email address to my email address. so the smtp address will be constant. (although in my code, I have it incorrect). The user will simply supply comments into a rich textbox and click a button on a windows form to submit the comments to me. what is the correct smtp addess for yahoo mail




    thanks
    shawn


  • Test Uzer

    Every user is going to have their own SMTP server, based on who they connect through.  You can't anticipate or discover this, you need to ask for it, then store it so they don't have to enter it every time.



  • are there any examples i can follow?