473,385 Members | 1,610 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,385 software developers and data experts.

Sending Mail

Hi,

I'm trying out a test mail script but it doesn't seem to work. The error I
get is that mail is not declared on the mail.To line.

Also, do I need to specify the SMTP Server? I have it commented out:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail" %>

<script runat="server">

Dim mail As New MailMessage()
mail.To = "xx**@xxxxx.com"
mail.From = "yo*@yourcompany.com"
mail.Subject = "this is a test email."

mail.BodyFormat = MailFormat.Html
mail.Body = "this is my test email body.<br><b>this part is in bold</b>"
'SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)
</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>
Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
1 1290
Hi,

try wiring the code into an event handler in the <script> element

Private Sub Page_Load(sender As Object,e As EventArgs) Handles MyBase.Load
'Code goes here
End Sub

And, yes it is recommended to specify the SMTP Server. It should use the
default local mail system (in IIS, placing eml files into directories) if
server isn't given, but it has had certain problems (though you'd face error
messages at that point). Just give it "localhost" or "127.0.0.1" and then
you might need to enable mail relaying in IIS SMTP Service (if you use it).

--
Teemu Keiski
ASP.NET MVP, Finland
"Joe via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> wrote in
message news:ce******************************@DotNetMonste r.com...
Hi,

I'm trying out a test mail script but it doesn't seem to work. The error I
get is that mail is not declared on the mail.To line.

Also, do I need to specify the SMTP Server? I have it commented out:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail" %>

<script runat="server">

Dim mail As New MailMessage()
mail.To = "xx**@xxxxx.com"
mail.From = "yo*@yourcompany.com"
mail.Subject = "this is a test email."

mail.BodyFormat = MailFormat.Html
mail.Body = "this is my test email body.<br><b>this part is in bold</b>"
'SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)
</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>
Thanks

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
3
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
3
by: HoustonComputerGuy | last post by:
I am working on getting my web applications moved to .Net 2.0 and am having some problems with System.Net.Mail. I get the following error when sending the mail: System.Net.Mail.SmtpException was...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: HK | last post by:
In VB.NET, I'm getting the exception "failure sending mail". I'm running VS 2005 on XP Home. This is a new install on a new PC. I've never had email problems with VS 2003, and there I could...
3
by: mfleet1973 | last post by:
Hello Again. I have a program that sends e-mails as follows: Try Dim mail As New MailMessage mail.To = "me@comp.com" mail.From = "me@comp.com mail.Subject = "Test" mail.Body = "Testing123"
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
4
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I use: Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) And its...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.