Home All Groups Group Topic Archive Search About
Author
2 May 2007 12:32 PM
5070707
Hi all!
I have a small form created with VS2005 (Visual Basic)
on that form i have 5 text boxes and 4 combo boxes.
(the 4 combo boxes are data bind to an sql 2000 DB)

i'v created a button and used an onclick snippet for sending email.
(it works :) )

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles EmailSubmitBTN.Click
        Dim message As New MailMessage("xxx@xxx", "xxx@xxx",
"subject", "A new request has arrived")
        Dim emailClient As New SmtpClient("xxx.xxx.xxx")
        emailClient.Send(message)

    End Sub

Now - the botton does work but i don't really know how to collect all
the data i'v placed in the text boxes and combo boxes to send it along
with the email msg.

so here i am, mumbling nervously to my self because i am no
programmer.. :)
any help with be greatly appreciates.....(code smaples will be mostly
appreciates)

Thanks!

50.

Author
2 May 2007 1:01 PM
Robin Tucker
Hi 5070707,


You just need to set the properties of your mail message object.  Such as:

With Message

    .From =
    .To =
    .Body =
    .Attachments.Add ( ... )

    etc....

End With


You can build the body by appending strings.  If speed is an issue here, use
the StringBuilder class.  Lookup the function reference for the MailMessage
class to get more information about what you can do with it and how it
works.

Also googling "MailMessage+VB.NET" brings up some more or less useful code
samples and demonstrations.




Robin
Author
2 May 2007 1:09 PM
rowe_newsgroups
> Also googling "MailMessage+VB.NET" brings up some more or less useful code
> samples and demonstrations.

One great site is www.systemnetmail.com

Thanks,

Seth Rowe
Author
2 May 2007 1:03 PM
rowe_newsgroups
On May 2, 8:32 am, 5070***@gmail.com wrote:
Show quoteHide quote
> Hi all!
> I have a small form created with VS2005 (Visual Basic)
> on that form i have 5 text boxes and 4 combo boxes.
> (the 4 combo boxes are data bind to an sql 2000 DB)
>
> i'v created a button and used an onclick snippet for sending email.
> (it works :) )
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles EmailSubmitBTN.Click
>         Dim message As New MailMessage("xxx@xxx", "xxx@xxx",
> "subject", "A new request has arrived")
>         Dim emailClient As New SmtpClient("xxx.xxx.xxx")
>         emailClient.Send(message)
>
>     End Sub
>
> Now - the botton does work but i don't really know how to collect all
> the data i'v placed in the text boxes and combo boxes to send it along
> with the email msg.
>
> so here i am, mumbling nervously to my self because i am no
> programmer.. :)
> any help with be greatly appreciates.....(code smaples will be mostly
> appreciates)
>
> Thanks!
>
> 50.

You can reference a control's property by using
"Me.ControlName.PropertyName" So in this case if you wanted the Text
property of a textbox named "TextBox1" you would use Me.TextBox1.Text.

So you could change your code to something like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles EmailSubmitBTN.Click
         Dim body As String = Me.TextBox1.Text & Me.TextBox2.Text &
Me.ComboBox1.Text ' etc
         Dim message As New MailMessage("xxx@xxx", "xxx@xxx",
"subject", body)
         Dim emailClient As New SmtpClient("xxx.xxx.xxx")
         emailClient.Send(message)
End Sub

Thanks,

Seth Rowe