Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
i want to send mails from xyz@anydomain.com to other domains like yahoo,rediff,etc. in my code already an smtp server is declare according our application its named as xyz@abc.co.uk.when 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;
              }
              else
              {
                  strFrom = ddlexisting.SelectedItem.Text;
              }
              strSubject = txtcreate.Text;
              int iport = 25;
              strBody = Editor1.Content;
 
              int intresult = email.SendEmail(strFrom, strTo, strSubject, strBody, iport);
              try
              {
                  if (intresult == 0)
                  {
                      insertsendemaildetail();
                  }
              }
              catch (SmtpException exception)
              {
                  //lblfpError.Text = "Message: " + exception.Message + ", Status Code: " + exception.StatusCode.ToString();
              }
         }
Posted 16-Apr-12 1:53am
Ramu15810
Edited 16-Apr-12 2:43am
V.41K
v2
Comments
9 from ap at 16-Apr-12 6:54am
   
can you share your code?
V. at 16-Apr-12 7:44am
   
Added code to question in code tags.
Rate this: bad
good
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.
  Permalink  
Comments
Ramu15 at 16-Apr-12 8:06am
   
It is not showing any error messages
Mark Nischalke at 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
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
You can acheive this by using the system.net. Actually Iwas facing some problem while using system.net
 
I have searched in the net for 2-3 days and finally I got a solution. I tried system.webmail insted of system.net and it works fine. Then I got to know that my server was not supporting system.net
 
Thanks
Tapan kumar
  Permalink  
Rate this: bad
good
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();
	try{
		//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"));
		smptclient.Send(mail);
		result = true;
	}			//end try
	catch(Exception ex){
		//Do something with exception here
	}			//end catch
	finally{
		mail.Dispose();	
	}					//end finally
	return result;
}
 
 
Hope this helps.
  Permalink  
v2
Comments
Mark Nischalke at 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. at 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. at 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 at 16-Apr-12 8:43am
   
It is not necessary to create your own element in config file for MailServer settings. It already exists. http://msdn.microsoft.com/en-us/library/w355a94k(v=vs.90).aspx

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

  Print Answers RSS
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2014
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