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

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*****@somewhere.com; // hard-coded
mail.To = pl******@somewhere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);

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 2514
Leszek,

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

Try using: txtEmail.Text.ToString instead.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Leszek" <ta******@5thbusiness.com> wrote in message
news:O$****************@tk2msftngp13.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*****@somewhere.com; // hard-coded
mail.To = pl******@somewhere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);

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******@5thbusiness.com> wrote in message
news:O$**************@tk2msftngp13.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*****@somewhere.com; // hard-coded
mail.To = pl******@somewhere.com;
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);

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
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...
0
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; //...
6
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...
5
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
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...
9
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...
2
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...
1
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. ...
19
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...

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.