Designing Email Msg.

  • Thread starter Thread starter 5070707
  • Start date Start date
5

5070707

Hi all!

I have a small form build with visual studio 2005 (Visual Basic)
in that form i have some text boxes and some combos.
these are being field by the users followed by an mail submit button i
created using a snipet.

the button code:

Private Sub butmail_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butmail.Click
Dim body As String = Me.DateTimePicker1.Text()
Dim message As New MailMessage("(e-mail address removed)", "(e-mail address removed)",
"Computer Notice", body)
Dim emailClient As New SmtpClient("aaa.aaa.aaa")
emailClient.Send(message)

End Sub
End Class

Now, the email does arrive containing the data that the user typed in
the fields,
but the data comes as a stright string with no spaces in the msg body.

im looking to understand how can i design the way the msg arrived at
the email box.
lets say for example..

name: the data
owner: the data
last upgrade: data
etc...

bare in mind that it took me ages to perform this small form :) i have
no idea in programing what so ever, just following the logic...
so code samples would be greatly appriciated!

thanks for everything!

50.
 
Hi all!

I have a small form build with visual studio 2005 (Visual Basic)
in that form i have some text boxes and some combos.
these are being field by the users followed by an mail submit button i
created using a snipet.

the button code:

Private Sub butmail_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butmail.Click
Dim body As String = Me.DateTimePicker1.Text()
Dim message As New MailMessage("(e-mail address removed)", "(e-mail address removed)",
"Computer Notice", body)
Dim emailClient As New SmtpClient("aaa.aaa.aaa")
emailClient.Send(message)

End Sub
End Class

Now, the email does arrive containing the data that the user typed in
the fields,
but the data comes as a stright string with no spaces in the msg body.

im looking to understand how can i design the way the msg arrived at
the email box.
lets say for example..

name: the data
owner: the data
last upgrade: data
etc...

bare in mind that it took me ages to perform this small form :) i have
no idea in programing what so ever, just following the logic...
so code samples would be greatly appriciated!

thanks for everything!

50.

How about:

' Typed in message
Private Sub butmail_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butmail.Click
Dim body As String = String.Format("<b>Name: </b>{0}<br />",
Me.NameTextBox.Text)
body &= String.Format("<b>Owner: </b>{0} <br />",
Me.OwnerTextBox.Text)
body &= String.Format("<b>Last Upgrade: </b>{0} <br />",
Me.LastUpgradeTextBox.Text)
' etc
Dim message As New MailMessage("(e-mail address removed)",
"(e-mail address removed)",
"Computer Notice", body)
message.IsBodyHtml = True
Dim emailClient As New SmtpClient("aaa.aaa.aaa")
emailClient.Send(message)
End Sub
End Class

Thanks,

Seth Rowe
 
How about:

' Typed in message
Private Sub butmail_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butmail.Click
Dim body As String = String.Format("<b>Name: </b>{0}<br />",
Me.NameTextBox.Text)
body &= String.Format("<b>Owner: </b>{0} <br />",
Me.OwnerTextBox.Text)
body &= String.Format("<b>Last Upgrade: </b>{0} <br />",
Me.LastUpgradeTextBox.Text)
' etc
Dim message As New MailMessage("(e-mail address removed)",
"(e-mail address removed)",
"Computer Notice", body)
message.IsBodyHtml = True
Dim emailClient As New SmtpClient("aaa.aaa.aaa")
emailClient.Send(message)
End Sub
End Class

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

Seth!!! Thank you so much!!!
Works great!!!

could i bother you with one lastttttt question?!

how can i popup a dialog box after the user pressed the button "Email
Sent!" and clear the form for next data?

50.
 
could i bother you with one lastttttt question?!
how can i popup a dialog box after the user pressed the button "Email
Sent!" and clear the form for next data?

Hey that's two questions! :-)

If MessageBox.Show("Do you want to clear the form?", "Clear
Form?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
Windows.Forms.DialogResult.Yes Then
' There are other ways to clear the text properties
' of every control on the form than clearing them
' individually, but since you are just starting you
' might want to stick with this simple approach
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
' etc
End If

Thanks,

Seth Rowe
 
Hey that's two questions! :-)

If MessageBox.Show("Do you want to clear the form?", "Clear
Form?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
Windows.Forms.DialogResult.Yes Then
' There are other ways to clear the text properties
' of every control on the form than clearing them
' individually, but since you are just starting you
' might want to stick with this simple approach
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
' etc
End If

Thanks,

Seth Rowe


"Hey that's two questions! :-)" -> why stick to semantics ? :)

should i just paste this under the button code?
 
Hey that's two questions! :-)

If MessageBox.Show("Do you want to clear the form?", "Clear
Form?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
Windows.Forms.DialogResult.Yes Then
' There are other ways to clear the text properties
' of every control on the form than clearing them
' individually, but since you are just starting you
' might want to stick with this simple approach
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
' etc
End If

Thanks,

Seth Rowe

Works like a charm!
so much thanks seth!!

50.
 
Back
Top