473,513 Members | 2,525 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*****@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 2527
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
1595
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
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; //...
6
2436
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
2133
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
1073
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
1839
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
1494
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
2238
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
3352
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
7161
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
7539
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...
1
7101
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
7525
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...
0
5686
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
3234
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.