472,378 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 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 2153
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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.