473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
3 2230
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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Squid Seven | last post by:
This is just bizarre. for the following snippet of code: #include <string> using std::string; I get the error message:
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
7
by: Aaron G via AccessMonster.com | last post by:
Wanted to share a solution to something which I didn't find on the net: EVERY form in my Microsoft Access 2002 database gave an error any time any code was to be called: form OnOpen, button...
5
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.