|
-
May 23rd, 2005, 03:04 AM
#1
Thread Starter
Lively Member
send email from an .aspx page
how do i write some codes to send email from
an .aspx page? thanks.
-
May 23rd, 2005, 04:36 AM
#2
Frenzied Member
Re: send email from an .aspx page
Code:
MailMessage mail = new MailMessage();
mail.From = "[email protected]";
mail.To = "[email protected]";
mail.Subject = "This is the subject";
mail.Body = "This is the message";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
You need to reference the System.Web.Mail namespace for that to work. Also you need to check which SMTP server you can use to send the message (in most cases it is localhost though).
This might help too -> http://www.aspheute.com/english/20000918.asp
HTH
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
May 24th, 2005, 09:57 PM
#3
Lively Member
Re: send email from an .aspx page
might need this too...interesting =)
-
Jun 6th, 2005, 07:11 AM
#4
Addicted Member
Re: send email from an .aspx page
Hellow,
I'm looking for a way to mail in the background.. I tried this but it wont work.. Is there anything I maybe forgot?
greetz
nickname
Software Engineer
DBA
Webdesigner
--
to code or to be coded, that's the question
-
Jun 9th, 2005, 11:31 AM
#5
Member
Re: send email from an .aspx page
You can check the following
1) In the above code the SMTP server being used is "localhost".
Code:
SmtpMail.SmtpServer = "localhost";
This means that the server hosting your ASP.Net application is itself the SMTP server. If this is not the case then replace "localhost" by the SMTP address or the IP address of the SMTP server to be used.
2) Check to see what authentication method you are using for the application. It can be possible that the user may not be authenticated for the SMTP server. Add the following code to specify some more details before sending the mail.(This code is in c#)
Code:
//Set Mode to basic authentication
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//set your username here
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userName");
//set your password here
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
//set the SMTP server port number here. Default is 25
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
Hope this helps.
Nikhil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|