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

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

P: n/a
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 = "fr**@microsoft.com"
myMail.To = "to@microsoft.com"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Did you add the System.Web.Dll reference. T

his works for me!

OHM

"rdi" <rd**@writeme.com> wrote in message news:eB****************@TK2MSFTNGP12.phx.gbl...
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 = "fr**@microsoft.com"
myMail.To = "to@microsoft.com"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class

Nov 20 '05 #2

P: n/a
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 news:eF**************@TK2MSFTNGP09.phx.gbl...
Did you add the System.Web.Dll reference. T

his works for me!

OHM

"rdi" <rd**@writeme.com> wrote in message news:eB****************@TK2MSFTNGP12.phx.gbl...
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 = "fr**@microsoft.com"
myMail.To = "to@microsoft.com"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
SmtpMail.Send(myMail)
End Class

Nov 20 '05 #3

P: n/a
* "rdi" <rd**@writeme.com> scripsit:
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 = ...
....
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.