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 Yahoo.ca domain to any-other domain. but mail is not sending.
Code is:

C#
protected void SendMail()
    {
        var fromAddress = YourEmail.Text.ToString();
        var toAddress = "abc@yahoo.ca";// 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.mail.yahoo.ca";
            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)
    {
        try
        {
            SendMail();
            lblMsgSend.Text = "Your Comments after sending the mail";
            lblMsgSend.Visible = true;
            YourSubject.Text = "";
            YourEmail.Text = "";
            YourName.Text = "";
            Comments.Text = "";
        }
        catch (Exception) { }
    }
Posted
Updated 31-Oct-13 1:44am
v2
Comments
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 Yahoo.ca domain to any-other domain. No error occur , but abc@yahoo.ca 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 "abc@yahoo.ca" 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 = "smtp.mail.yahoo.ca";
it Must Be
C#
SmtpServer.Host = "smtp.mail.yahoo.com";
 
Share this answer
 
Hi,

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.

Thanks!
 
Share this answer
 
Check this settings with your code:-

C#
SmtpServer.Host = "smtp.mail.yahoo.com";
Or
SmtpServer.Host = " plus.smtp.mail.yahoo.com";
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#[^]

2> http://www.aspdotnet-suresh.com/2010/11/introduction-this-article-i-will.html[^]

3> http://www.orcsweb.com/blog/brad/sending-email-from-asp-net-4-c-sample-code/[^]

Hopefully Help you :
----------------------------
Vishnu Prajapati
 
Share this answer
 
v3
 
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 " smtp.host="smtp.mail.yahoo.com" and "smtp.EnableSsl=false" try this, it might help...
 
Share this answer
 
v2
You can follow the link and find out a very helpful guide:
- http://tekkiebooks.com/Product/9db79251-4ddb-42c5-819e-873cce0f4d5f/codeproject_01[^]

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