Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
Old 10-31-2007, 09:42 AM SmtpClient Mail.Send
pjb007's Avatar
Super Talker

Posts: 104
Location: UK
Trades: 0
I am trying to get an ASP.NET email form to run using C#

Here is my code:
Code:
SmtpClient Mail = new SmtpClient("smtp.mydomain.com");
        Mail.Send("myemail@ddress.com", txtEmail.Text,
                  txtName.Text, txtMessage.Text, txtPref.Text);
When I run that I get the following error message:
Quote:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1501: No overload for method 'Send' takes '5' arguments
If I take out txtName or txtMessage or txtPref it works, is there a way to get it to work with all of them?
__________________
pjb007
pjb007 is offline
Reply With Quote
View Public Profile Visit pjb007's homepage!
 
 
Register now for full access!
Old 10-31-2007, 04:50 PM Re: SmtpClient Mail.Send
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
No ...
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-31-2007, 05:16 PM Re: SmtpClient Mail.Send
pjb007's Avatar
Super Talker

Posts: 104
Location: UK
Trades: 0
It seems strange that you cant send send more than five things.
__________________
pjb007
pjb007 is offline
Reply With Quote
View Public Profile Visit pjb007's homepage!
 
Old 10-31-2007, 05:38 PM Re: SmtpClient Mail.Send
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Compiler Error Message: CS1501: No overload for method 'Send' takes '5' arguments
Why strange??

put the error message and the fact that taking out one item works and you have your answer.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-31-2007, 05:41 PM Re: SmtpClient Mail.Send
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
or maybe if you read

SmtpClient.Send Method
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-01-2007, 07:50 AM Re: SmtpClient Mail.Send
pjb007's Avatar
Super Talker

Posts: 104
Location: UK
Trades: 0
I've just tried another method of sending emails run the programme and that only takes 4 arguments.

Why does it limit the number of fields you can have?
__________________
pjb007
pjb007 is offline
Reply With Quote
View Public Profile Visit pjb007's homepage!
 
Old 11-01-2007, 08:01 AM Re: SmtpClient Mail.Send
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
because that is what it is designed with.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-19-2007, 11:19 PM Re: SmtpClient Mail.Send
webspinner's Avatar
Novice Talker

Posts: 7
Trades: 0
Use System.Web.Mail.MailMessage class

Quote:
Originally Posted by pjb007 View Post
I am trying to get an ASP.NET email form to run using C#

Here is my code:
Code:
SmtpClient Mail = new SmtpClient("smtp.mydomain.com");
        Mail.Send("myemail@ddress.com", txtEmail.Text,
                  txtName.Text, txtMessage.Text, txtPref.Text);
When I run that I get the following error message:


If I take out txtName or txtMessage or txtPref it works, is there a way to get it to work with all of them?
webspinner is offline
Reply With Quote
View Public Profile
 
Old 01-19-2008, 05:47 AM Re: SmtpClient Mail.Send
Junior Talker

Posts: 4
Trades: 0
You have to create a MailMessage object and add everything you need to that, then use the MailMessage object in the send method:

SmtpClient _smtp = new SmtpClient();
MailMessage _mm = new MailMessage();
_mm.From = new MailAddress(_strFrom);
_mm.To.Add(new MailAddress(_strTo));
_mm.Subject = _strSubject;
_mm.IsBodyHtml = true;
_mm.Body = _strBody;
_smtp.Send(_mm);
__________________

Please login or register to view this content. Registration is FREE
- Secure financial investment for your new or existing website
WebInvestors is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to SmtpClient Mail.Send
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.80278 seconds with 12 queries