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

Problem In sending mail in asp.net

10.2 How to send emails by using System.Net.Mail [top]
CODE-BEHIND:
Expand|Select|Wrap|Line Numbers
  1. MailMessage message = new MailMessage();
  2. message.From = new MailAddress("fromusername@DomainName");
  3. message.To.Add(new MailAddress("tousername@DomainName"));
  4. message.CC.Add(new MailAddress("ccusername@DomainName"));
  5. message.Subject = "Subject";
  6. message.Body = "Content";
  7. SmtpClient client = new SmtpClient();
  8. client.Send(message);
web.config:

Expand|Select|Wrap|Line Numbers
  1. <system.net>
  2.     <mailSettings>
  3.         <smtp from="username@DomainName">
  4.             <network host="SMTPServerName" port="25" userName="username" password="secret" defaultCredentials="true" />
  5.         </smtp>
  6.     </mailSettings>
  7. </system.net>


i m sending mail by this method but it generate exception"SMTP EXCEPTION NOT HANDELED BY USER"
and in details it shows as:
"base {System.Exception} = {"Failure sending mail."}
[System.Net.Mail.SmtpException] = {"Failure sending mail."}
StackTrace = " at System.Net.Mail.SmtpClient.Send(MailMessage message)\r\n at ExptMail.Button1_Click(Object sender, EventArgs e) in f:\\dh\\websites\\ExptMail.aspx.cs:line 32""
Aug 31 '10 #1
1 1649
Frinavale
9,735 Expert Mod 8TB
Looks like you need to provide user credentials in order to send the email. Check out this quick reference on how to send an email using .NET. It explains how to do this.

Also, double check that you are using the correct port.

-Frinny
Aug 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gerhard Häring | last post by:
On my mailserver (running a recent Postfix snapshot) I get this since a few hours: mylene:/var# mailq -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- DA10713E37 1617 Wed...
3
by: Serge Myrand | last post by:
Hi everybody, The following code for sending email (found on msn I think) works find when used in a .VBS file. I double click the file and the mail is send. When I use the same code in my .ASP...
2
by: Brent | last post by:
Hi, I have a C# asp.net app that sent mail fine on server 2000 or win 2000, but now I moved it to our new 2003 box, and it's giving me "The 'SendUsing' configuration is invalid" This is the code...
1
by: Robert Dufour | last post by:
I a m trying to send e-mails using the system.net.mail in framework2. I have IIS installed on my test box and the smtp service is started. I can use outlook on that box to send and receive my...
0
by: Parz | last post by:
Hi can somebody please help me.. I have a web page from which the new members can mail me with their details.What i have done is, I have created a form with all details and an attachment upload...
0
by: Pav | last post by:
Hi, I am developing a small Intranet web application which needs to send mails to our coporate Ids. I am using CDONTS, But my mails never leave Que folder. Not able to find out what the...
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
4
by: bgs | last post by:
i'm trying to send mail from asp server in two ways, the first uses CDONTS.Newmail: <% Dim objCDOMail Set objCDOMail = Server.CreateObject("CDONTS.NewMail") objCDOMail.BodyFormat = 1 ...
4
by: vivekshekar | last post by:
I'm using Ubuntu OS, I'm trying to send a mail through a program, but I'm not able to do this. This is the program, <?php $Name = "xxx";
3
by: AbusiveMeercat | last post by:
Ugh this is so frustrating. This code doesn't work for some reason...Can anybody help me fix it? class MainClass { public static void Main (string args) { MainClass mailman = new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.