"Declaration Expected" - Copy/Pasted DIRECTLY from the help files.

R

rdi

The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line results in a "Declaration Expected" error.

--

RDI

(remove the exclamation from the email address)

Imports System.Web
Imports System.Web.Mail
Imports System.Web.Mail.SmtpMail
Imports System.Web.Mail.MailAttachment
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.MailFormat
Public Class myEMail
Dim myMail As New MailMessage()
myMail.From = "(e-mail address removed)"
myMail.To = "(e-mail address removed)"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class
 
O

One Handed Man \( OHM#\)

Did you add the System.Web.Dll reference. T

his works for me!

OHM

The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line results in a "Declaration Expected" error.

--

RDI

(remove the exclamation from the email address)

Imports System.Web
Imports System.Web.Mail
Imports System.Web.Mail.SmtpMail
Imports System.Web.Mail.MailAttachment
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.MailFormat
Public Class myEMail
Dim myMail As New MailMessage()
myMail.From = "(e-mail address removed)"
myMail.To = "(e-mail address removed)"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class
 
R

rdi

Yes that was already added.

But I found it. This was a STUPID mistake. That code was in the class--but not inside a sub or function. It dawned on me about 10 seconds AFTER I pressed SEND--just enough time for me to really feel like a fool. DUH! <grin>

--

RDI

(remove the exclamation from the email address)

"One Handed Man ( OHM#)" <news.microsoft.com> wrote in message Did you add the System.Web.Dll reference. T

his works for me!

OHM

The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line results in a "Declaration Expected" error.

--

RDI

(remove the exclamation from the email address)

Imports System.Web
Imports System.Web.Mail
Imports System.Web.Mail.SmtpMail
Imports System.Web.Mail.MailAttachment
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.MailFormat
Public Class myEMail
Dim myMail As New MailMessage()
myMail.From = "(e-mail address removed)"
myMail.To = "(e-mail address removed)"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class
 
H

Herfried K. Wagner [MVP]

* "rdi said:
The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file.  Starting with
the myMail.From line and going down to the SmtpMail.Send line, EVERY line results in a "Declaration Expected" error.

Instead of creating a new class, use something like this:

\\\
Dim myMail As New MailMessage()
MyMail.From = ...
....
///
 

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

Top