Home All Groups Group Topic Archive Search About
Author
31 Mar 2006 7:26 PM
James Robertson
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, "M*@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

Author
1 Apr 2006 2:26 AM
Homer J Simpson
Show quote Hide quote
"James Robertson" <jrobert***@calaveras.k12.ca.us> wrote in message news:536CB917-5B11-4D90-B048-747049CC97BA@microsoft.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.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, "M*@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