By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

SENDMail

P: n/a
Issue is that I really do not know diddly. Copying and trying to learn as
much as I can about VB and ASP2.0. Now the question I have is I created an
E-Mail form the sendmail properties in the VB side are

Imports System.Net.Mail

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.WizardNavigationEventArg s) Handles
Wizard1.FinishButtonClick
SendMail(TXTEMail.Text, TXTComments.Text)
End Sub

Private Sub SendMail(ByVal from As String, ByVal body As String)
Dim mailServerName As String = "My.Mail.Server"
Dim message As MailMessage = New MailMessage(from, "MY@email.com",
"Sent from E-Form", body)
Dim mailClient As SmtpClient = New SmtpClient
mailClient.Host = mailServerName
mailclient.Send(message)
message.Dispose()
End Sub

The problem is I have four items that I want sent to me but right now all I
can get are the two listed in SendMail(TXTEMail.Text, TXTComments.Text) I
also want my Subject and Name boxes sent as well. If i add them to the
SendMail(TXTEMail.Text, TXTComments.Text) I get an error. What am I doing
wrong and do i have this all wrong? Help in coding would be appreciated and
where it goes.

Thanks in advance
Mar 31 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"James Robertson" <jr********@calaveras.k12.ca.us> wrote in message news:53**********************************@microsof t.com...
Issue is that I really do not know diddly. Copying and trying to learn as
much as I can about VB and ASP2.0. Now the question I have is I created an
E-Mail form the sendmail properties in the VB side are

Imports System.Net.Mail

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.WizardNavigationEventArg s) Handles
Wizard1.FinishButtonClick
SendMail(TXTEMail.Text, TXTComments.Text)
End Sub

Private Sub SendMail(ByVal from As String, ByVal body As String)
Dim mailServerName As String = "My.Mail.Server"
Dim message As MailMessage = New MailMessage(from, "MY@email.com",
"Sent from E-Form", body)
Dim mailClient As SmtpClient = New SmtpClient
mailClient.Host = mailServerName
mailclient.Send(message)
message.Dispose()
End Sub

The problem is I have four items that I want sent to me but right now all I
can get are the two listed in SendMail(TXTEMail.Text, TXTComments.Text) I
also want my Subject and Name boxes sent as well. If i add them to the
SendMail(TXTEMail.Text, TXTComments.Text) I get an error. What am I doing
wrong and do i have this all wrong? Help in coding would be appreciated and
where it goes.

Thanks in advance


Use this and hack it to suit:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load

Dim myTo As MailAddress, myFrom As MailAddress

Dim myClient As SmtpClient, myMessage As MailMessage



'A simple message

myMessage = New MailMessage("Person1_AT_mail_DOT_com", "Person2_AT_mail_DOT_com", _

"This is the simple subject", "This is the simple body")

myClient = New SmtpClient("smtp.server.net")

myClient.Send(myMessage)



'A more complex example

myTo = New MailAddress("Person1_AT_mail_DOT_com", "FirstNameA SecondNameA")

myFrom = New MailAddress("Person2_AT_mail_DOT_com", "FirstNameB SecondNameB")

myMessage = New MailMessage(myFrom, myTo)

myMessage.To.Add("Person3_AT_mail_DOT_com")

myMessage.Bcc.Add("Person4_AT_mail_DOT_com")

myMessage.Subject = ("This is the subject")

myMessage.IsBodyHtml = True

myMessage.Body = ("<B>This is the body</B>")

myMessage.Attachments.Add(New Attachment("C:\MyLargeImage1.bmp"))

myMessage.Attachments.Add(New Attachment("C:\MyLargeImage2.bmp"))

myMessage.Attachments.Add(New Attachment("C:\MySmallImage1.bmp"))

myMessage.Attachments.Add(New Attachment("C:\MySmallImage2.bmp"))

'myClient = New SmtpClient("smtp.server.net")

myClient.Send(myMessage)

End Sub

Apr 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.