Help! Code for Sending Emails

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I receive an error with the following language (error message indicate at ** below)

Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Clic
Dim DBConn As SqlConnectio
Dim DBCommand As SqlDataAdapte
Dim DSPageData As New DataSe
Dim TheMailMessage As New MailMessag
** Dim TheMailConnection As SmtpMail 'This s/b New SmtpMail - I receive the following error with
** 'TheMailConnection when I put New in:
** ' 'System.Web.Mail.SmtpMail.Private Sub New()' is not accessible in this context because it is 'Private
Dim I As Intege
DBConn = New SqlConnection("data source=z;initial catalog=C4EmailBlast;integrated security=SSPI;"
DBCommand = New SqlDataAdapter
("Select Distinct CustomerEmail from Customers "
& "Where GroupName= '"
& ddlGroupName.SelectedItem.Text & "'", DBConn
DBCommand.Fill(DSPageData, "Emails"
TheMailMessage.From = txtFrom.Tex
TheMailMessage.Subject = txtSubject.Tex
TheMailMessage.Body = txtMessage.Tex
For I = 0 To DSPageData.Tables("Emails").Rows.Count -
TheMailMessage.To = DSPageData.Tables("Emails").
Rows(0).Item("CustomerEmail"
TheMailConnection.Send(TheMailMessage

Nex
If DSPageData.Tables("Emails").Rows.Count = 1 The
lblMessage.Text = "Your message has been sent to 1"
& " person. You can now send another email blast.
Els
lblMessage.Text = "Your message has been sent to "
& DSPageData.Tables("Emails").Rows.Count
& " people. You can now send another email blast.
End I
End Su

Does anyone know why this error is being generated and how I can fix the code so it works

Any help you can give me will be greatly appreciated

Sand
 
You don't need that line at all. When you get to the point of sending it
you just need

Mail.SmtpMail.Send(TheMailMessage)


Sandy said:
I receive an error with the following language (error message indicate at ** below):

Sub btnOK_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnOK.Click
Dim DBConn As SqlConnection
Dim DBCommand As SqlDataAdapter
Dim DSPageData As New DataSet
Dim TheMailMessage As New MailMessage
** Dim TheMailConnection As SmtpMail 'This s/b New SmtpMail - I
receive the following error with
** 'TheMailConnection when I put New in:
** ' 'System.Web.Mail.SmtpMail.Private Sub New()' is not
accessible in this context because it is 'Private'
Dim I As Integer
DBConn = New SqlConnection("data source=z;initial
catalog=C4EmailBlast;integrated security=SSPI;")
 
Thank you very much! (I got that code, by the way, directly from a book: "Instant ASP.NET Applications. Osbourne." You'd think they'd proofread . . .

At any rate, I am now having the problem of the code running and appearing to have sent the email. (It shows no build errors prior to going to User Interface.) When I get out of the Web User Interface the following appears

Auto-attach to process '[968] w3wp.exe' on machine 'Z' succeeded
'DefaultDomain': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.directoryservices\1.0.5000.0__b03f5f7f11d50a3a\system.directoryservices.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.messaging\1.0.5000.0__b03f5f7f11d50a3a\system.messaging.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.serviceprocess\1.0.5000.0__b03f5f7f11d50a3a\system.serviceprocess.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.web.regularexpressions\1.0.5000.0__b03f5f7f11d50a3a\system.web.regularexpressions.dll', No symbols loaded
'DefaultDomain': Loaded 'i:\win2003\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\temporary asp.net files\emailmcadp359\b2be357b\b5366f8d\assembly\dl2\2ee81b32\801a5a15_8c08c401\emailmcadp359.dll', Symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\temporary asp.net files\emailmcadp359\b2be357b\b5366f8d\j73osqv2.dll', Symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\temporary asp.net files\emailmcadp359\b2be357b\b5366f8d\plyzmy8y.dll', Symbols loaded
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.directoryservices\1.0.5000.0__b03f5f7f11d50a3a\system.directoryservices.dll', No symbols loaded.
'/LM/w3svc/1/root/EmailMCADP359-2-127236267230802416': Loaded 'i:\win2003\assembly\gac\system.web.regularexpressions\1.0.5000.0__b03f5f7f11d50a3a\system.web.regularexpressions.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded.
'/LM/W3SVC/1/ROOT-3-127236279518270928': Loaded 'i:\win2003\assembly\gac\system.directoryservices\1.0.5000.0__b03f5f7f11d50a3a\system.directoryservices.dll', No symbols loaded.

<snip - just more of the same>

The program '[968] w3wp.exe: DefaultDomain' has exited with code 0 (0x0).
The program '[968] w3wp.exe: /LM/W3SVC/1/Root/EmailBlast-5-127236287691523488' has exited with code 0 (0x0).
The program '[968] w3wp.exe: /LM/W3SVC/1/ROOT-3-127236279518270928' has exited with code 0 (0x


Is there something that's supposed to go in a configuration page or is there possibly some component I am missing and should install? I did install smtp.
 
According to what you have included, there doesn't appear to be any errors.
Are you able to confirm that it did or did not send anything?
 
Back
Top