473,671 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with the SmtpMail.Send() method

Hello,

I have created a simple code to send emails using the MailMessage class and
the SmtpMail.Send() method:

MailMessage mail = new MailMessage();
mail.From = ec*****@somewhe re.com; // hard-coded
mail.To = pl******@somewh ere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html ;
SmtpMail.Send(m ail);

It works fine as long as the mail.From address is hard-coded. When I changed
the line to:
string strEmail = txtEmail.Value;
mail.From = strEmail;

txtEmail is an HTML server-control:
<input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail"
runat="server">

the code stopped working. I mean it does not send emails and even does not
throw any exception!!!
Is there any possibility to check the status of a sent message? Does
SmtpMail have any "error" property to check if the email has been sent
properly?
If I could not be sure that the message has been sent properly the
SmtpMail.Send() method would be of no use.

Please advice what to do. Should I use SmtpMail.Send() or maybe another
method?

Thanks for any hints,
Leszek Taratuta

Nov 17 '05 #1
2 2541
Leszek,

Is txtEmail.Value the equivalent of txtEmail.Text in VB.Net?

Try using: txtEmail.Text.T oString instead.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Leszek" <ta******@5thbu siness.com> wrote in message
news:O$******** ********@tk2msf tngp13.phx.gbl. ..
Hello,

I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method:

MailMessage mail = new MailMessage();
mail.From = ec*****@somewhe re.com; // hard-coded
mail.To = pl******@somewh ere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html ;
SmtpMail.Send(m ail);

It works fine as long as the mail.From address is hard-coded. When I changed the line to:
string strEmail = txtEmail.Value;
mail.From = strEmail;

txtEmail is an HTML server-control:
<input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail"
runat="server">

the code stopped working. I mean it does not send emails and even does not
throw any exception!!!
Is there any possibility to check the status of a sent message? Does
SmtpMail have any "error" property to check if the email has been sent
properly?
If I could not be sure that the message has been sent properly the
SmtpMail.Send() method would be of no use.

Please advice what to do. Should I use SmtpMail.Send() or maybe another
method?

Thanks for any hints,
Leszek Taratuta

Nov 17 '05 #2
Some mail servers are configured to perform DNS lookup to verify the domain
name of the from e-mail address. May be this is your problem.
"Leszek" <ta******@5thbu siness.com> wrote in message
news:O$******** ******@tk2msftn gp13.phx.gbl...
Hello,

I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method:

MailMessage mail = new MailMessage();
mail.From = ec*****@somewhe re.com; // hard-coded
mail.To = pl******@somewh ere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html ;
SmtpMail.Send(m ail);

It works fine as long as the mail.From address is hard-coded. When I changed the line to:
string strEmail = txtEmail.Value;
mail.From = strEmail;

txtEmail is an HTML server-control:
<input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail"
runat="server">

the code stopped working. I mean it does not send emails and even does not
throw any exception!!!
Is there any possibility to check the status of a sent message? Does
SmtpMail have any "error" property to check if the email has been sent
properly?
If I could not be sure that the message has been sent properly the
SmtpMail.Send() method would be of no use.

Please advice what to do. Should I use SmtpMail.Send() or maybe another
method?

Thanks for any hints,
Leszek Taratuta

Nov 17 '05 #3

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

Similar topics

4
1604
by: Xerox | last post by:
The SmtpMail class has a static property to set the server and a static method to send an email. But if its static, how can it work in a multithreaded environment? Surely one would want to create an instance of the server and invoke the send() method?
0
304
by: Leszek | last post by:
Hello, I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method: MailMessage mail = new MailMessage(); mail.From = echidna@somewhere.com; // hard-coded mail.To = platypus@somewhere.com; mail.Subject = "Test"; mail.Body = strMessage;
6
2448
by: Cameron Eckman | last post by:
I get various errors when I try to use email on the machine I have. XP professional. It works fine on another machine with NT 2000 server. Below is the code: 'BEGIN CODE Dim oMail As New MailMessage() With oMail .From = "mypc@baxglobal.com" .To = "ceckman@baxglobal.com"
5
2141
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. --------------------------------------------------------------------------------
2
1082
by: Foehammer | last post by:
I am using the standard .NET method of sending an email. My users will be filling out a web form with various pieces of information. I have created a control with properties that are the same as the items on the form. When the user clicks submit, my code is as follows: InformationRequest req = new InformationRequest(); req.FirstName = this.txtFirstName.Text; req.LastName = this.txtLastName.Text; req.Title = this.txtTitle.Text;...
9
1850
by: Russell Stevens | last post by:
I generate pdf files on my server and allow users to access them via a browser and also email them. Most files work fine whether the user uses his browser or gets an email with a pdf attachment which he can then open with Acrobat. All my pdf files work fine via a browser, but some are corrupted by one byte when sent as an email attachment. The problem is 100% reproducible - the code is trivial. Am I missing something obvious or is this a...
2
1500
by: Rene | last post by:
Hi all i need some help. i try to send mail with the following code. Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim mailMsg As New MailMessage mailMsg.From = rene.fehr@netradox.com mailMsg.To = info@netradox.com mailMsg.Subject = "Testmail vom Webforum" mailMsg.Body = "some body text"
1
2245
by: Phill. W | last post by:
Have Our Friends in Redmond put delay loops into the SMTPMail.Send() method, or does it /really/ take almost a second to send a mail message? I've written a windows service that send emails. It was originally intended for /small/ volume, direct communication with our clients. Somebody, however, has decided they want to send a message to the entire client-list - nearly 200,000 entries - and, at our current throughput, this will take us...
19
3361
by: zdrakec | last post by:
Hello all: Using an "Imports System.Web.Mail" clause at the head of my module, and after executing the following code: Dim msg As New MailMessage msg.From = sender msg.To = recipient msg.Attachments.Add(New MailAttachment(attachFile)) msg.Subject = subjectString
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8402
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8676
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7445
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.