Click here to Skip to main content
13,200,202 members (54,443 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to send mails from to other domains like yahoo,rediff,etc. in my code already an smtp server is declare according our application its named as i send mails its showing mail send successfully but the mail does not reaching to the user.

for (int i = 0; i < stremail.Length; i++)
              Email email = new Email();
              intuserid = int.Parse(struserid[i]);
              strTo = stremail[i];
              if (txtemailid.Text != string.Empty)
                  strFrom = txtemailid.Text;
                  strFrom = ddlexisting.SelectedItem.Text;
              strSubject = txtcreate.Text;
              int iport = 25;
              strBody = Editor1.Content;
              int intresult = email.SendEmail(strFrom, strTo, strSubject, strBody, iport);
                  if (intresult == 0)
              catch (SmtpException exception)
                  //lblfpError.Text = "Message: " + exception.Message + ", Status Code: " + exception.StatusCode.ToString();
Posted 16-Apr-12 0:53am
Updated 16-Apr-12 1:43am
9 from ap 16-Apr-12 6:54am
can you share your code?
V. 16-Apr-12 7:44am
Added code to question in code tags.
Mr. Tapan Kumar 10-Oct-12 15:41pm
Nice post really helpfull.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You should be using SmtpMail.Send[^] unless Email.Send is some wrapper you have created. Regardless, these methods only push the email to the SMTP server and does not guarantee delivery. There could be any number of issues preventing actual receipt, bad address, blocked sender, etc.
Ramu15 16-Apr-12 8:06am
It is not showing any error messages
Mark Nischalke 16-Apr-12 8:09am
As long as the objects are valid it will not show any exceptions. That doesn't mean the email was sent by the SMTP server or received by the client. Do some research.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


You can acheive this by using the Actually Iwas facing some problem while using

I have searched in the net for 2-3 days and finally I got a solution. I tried system.webmail insted of and it works fine. Then I got to know that my server was not supporting

Tapan kumar
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Id did it like this (.Net 4.0):
private bool Send(){
	bool result = false;
	MailMessage mail = new MailMessage();
		//Attaches email addresses to the MailMessage object
		GetAdressesTo(ref mail); 
		//Attaches email addresses to the MailMessage object
		GetAdressesCc(ref mail); 
		mail.From	= new MailAddress(txtbox_mailfrom.Text);
		mail.Subject	= txtbox_mailsubject.Text;
		mail.Body	= txtbox_mailtext.Text;
		SmtpClient smptclient = new SmtpClient(ConfigurationSettings.GetConfigurationSetting("MailServer"));
		result = true;
	}			//end try
	catch(Exception ex){
		//Do something with exception here
	}			//end catch
	}					//end finally
	return result;

Hope this helps.
Mark Nischalke 16-Apr-12 8:12am
And how does this answer the question? You have just provided useless and confusing clutter with functionality the OP is not using and didn't ask for.
V. 16-Apr-12 8:25am
He asked how to send a mail via SMTP, which is what I did. I admit I could have cleaned it a little more, but the code is correct and working. I'm not perfect, just trying to help.
V. 16-Apr-12 8:32am
There, I cleaned it a little, it uses the same object you recommend so it shouldn't be hard for the OP to understand.
Mark Nischalke 16-Apr-12 8:43am
It is not necessary to create your own element in config file for MailServer settings. It already exists.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100