Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Hello , My question is:

Send Email , From domain to any-other domain. but mail is not sending.
Code is:

protected void SendMail()
        var fromAddress = YourEmail.Text.ToString();
        var toAddress = "";// Email Address from where you send the mail
        const string fromPassword = "12345678";//Password of your email address
        string subject = YourSubject.Text.ToString();
        string body = "From: " + YourName.Text + "\n";
        body += "Email: " + YourEmail.Text + "\n";
        body += "Subject: " + YourSubject.Text + "\n";
        body += "Question: \n" + Comments.Text + "\n";

        var smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "";
            smtp.Port = 587;  
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
            smtp.Timeout = 20000;
        smtp.Send(fromAddress, toAddress, subject, body);     

    protected void Button1_Click(object sender, EventArgs e)
            lblMsgSend.Text = "Your Comments after sending the mail";
            lblMsgSend.Visible = true;
            YourSubject.Text = "";
            YourEmail.Text = "";
            YourName.Text = "";
            Comments.Text = "";
        catch (Exception) { }
Updated 31-Oct-13 1:44am
VICK 31-Oct-13 7:47am    
What error or exception does the code throwing??? or have not you used the debugger?

It can be the issue of wrong smtp port. have you confirmed that?
Inderveer kaur 4-Nov-13 7:39am    
hello sir , I want to send mail From domain to any-other domain. No error occur , but doesnot receive error. please help me sir ,nobody find my problem...

VICK 4-Nov-13 7:50am    
Shared some links. i.e. from CP and some external. Do have a look at those. and first try to understand the working scenario and than try to implement that. Hope that gonna solve your problem.
Inderveer kaur 5-Nov-13 6:57am    
Sir, Using this code, Email which i've used in code "" doesnot receive any email from fromAddress (variable name in code) , email which enter by user.
What do you mean by not sending? Is there any Error or Exception?

See this Line
smtp.Host = "";
it Must Be
SmtpServer.Host = "";
Share this answer

Mail sending will happen through your SMTP port.

Consider & Check for following.

1.SMTP port is enabled
2.SMTP port should not be blocked by any application or if office System the port may be closed
3.Use TELNET and enter port Number to check the same.
4.Check Antivirus / Firewall is blocking the port.

if onceeverything is fine the environment is fine, you can also debug and check for proper code used.

Share this answer
Check this settings with your code:-

SmtpServer.Host = "";
SmtpServer.Host = "";
smtp.Port = 465;
smtp.EnableSsl = true;
Share this answer
Following Link is very Useful to you :

1> Send Mail / Contact Form using ASP.NET and C#[^]



Hopefully Help you :
Vishnu Prajapati
Share this answer
Share this answer
have a look at the following Links. and adjust your credentials accordingly to use yahoo domain.

SMTP etc settings for Yahoo.

Send Email from Yahoo!, GMail, Hotmail (C#)

Sending Email with Gmail, Yahoo, AOL, and Live Mail Via SMTP

Hope it will help.

Share this answer
Please check that smtp host: it should be """ and "smtp.EnableSsl=false" try this, it might help...
Share this answer
You can follow the link and find out a very helpful guide:

Good luck!
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900