|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sending MailI 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. 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 > Also googling "MailMessage+VB.NET" brings up some more or less useful code One great site is www.systemnetmail.com> samples and demonstrations. Thanks, Seth Rowe On May 2, 8:32 am, 5070***@gmail.com wrote:
Show quoteHide quote > Hi all! You can reference a control's property by using> 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. "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
Deleting blanks in a string
Show Msgbox in SYSTEM account System tray icon does not always show when starting app when Windows starts Best method to parse this flat file Suggestions to learn vb.net Datasource question If else and what ever :( (Newbie) Help.ShowPopup for all Textboxes on Form? Access DB Upgrade get DB results from inner join update |
|||||||||||||||||||||||