SENDMail

G

Guest

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.WizardNavigationEventArgs) 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, "(e-mail address removed)",
"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
 
H

Homer J Simpson

James Robertson said:
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.WizardNavigationEventArgs) 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, "(e-mail address removed)",
"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error with SMTP 3
Error with SMTP 3
SMTP: Bad Sequence of Commands 1
SmtpClient authentication 3
Weird system.net.mail behaviour 4
SMTP Email VB.net 2008 4
System.Web.Mail send mail fails 4
SMTP Mail Problem 4

Top