Hi to all,
i want to send mail using yahoo or hotmail id any one can help me.
i have a code which is able to send mail using gmail id.
for gmail i am using the port no : 587
and smtp.Host = "smtp.gmail.com"
and for yahoo i am using port no=25
and amtp.Host=smtp.mail.yahoo.com
but when i am using yahoo or hotmail id it is not working plz help me out
any suggesstion welcome.
Rahul Singi
Loading

Lalit MRank #1,186 · 1.5K reputationPosted Feb 10, 2010, 2:47 AM EST
http://forums.asp.net/p/1472620/3414566.aspx
charles henington4 reputationPosted May 3, 2010, 11:51 PM EDT
to send via yahoo the code is
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Net.Mail;
using System.Net.Mime;
using System.Windows.Forms;
namespace EmailClient
{
public partial class YahooForm : Form
{
MailMessage mail = new MailMessage();
public YahooForm()
{
InitializeComponent();
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
// textBox1.Text will be the address that you are sending the mail message to
using (MailMessage mailMessage = new MailMessage(new MailAddress(textBox1.Text),
new MailAddress(textBox1.Text)))
{
mailMessage.Body = textBox5.Text;
mailMessage.Subject = textBox4.Text;
try
{
SmtpClient SmtpServer = new SmtpClient();
// textBox2.Text is username and textBox3.Text is password
SmtpServer.Credentials = new System.Net.NetworkCredential(textBox2.Text, textBox3.Text);
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.mail.yahoo.com ";
SmtpServer.EnableSsl = false;
mail = new MailMessage();
String[] addr = textBox1.Text.Split(',');
mail.From = new MailAddress(textBox2.Text);
Byte i;
for (i = 0; i < addr.Length; i++)
mail.To.Add(addr[i]);
mail.Subject = textBox4.Text;
mail.Body = textBox5.Text;
if (listBox1.Items.Count != 0)
{
for (i = 0; i < listBox1.Items.Count; i++)
mail.Attachments.Add(new Attachment(listBox1.Items[i].ToString()));
}
mail.IsBodyHtml = true;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(textBox1.Text);
SmtpServer.Send(mail);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
// you can use a listbox to add attachments just use add dialog to add attachments to your list box
To Send email with hotmail you use the same code only add
Using System.Net;
and then add
NetworkCredential cred = new NetworkCredential(textBox2.Text, textBox3.Text);
between
SmtpClient SmtpServer = new SmtpClient();
and
SmtpServer.Credentials = new System.Net.NetworkCredential(textBox2.Text, textBox3.Text);
Finally change
SmtpServer.Host = "smtp.mail.yahoo.com ";
to
//smtp.live.com if a live account but smtp.hotmail.com if hotmail account
SmtpServer.Host = "smtp.live.com ";
and change SmtpServer.EnableSsl = false;
to
SmtpServer.EnableSsl = true;
Good luck to you friend
Lalit MRank #1,186 · 1.5K reputationPosted Feb 10, 2010, 6:44 PM EST
Your Yahoo Mail account POP3 & SMTP server details may vary according to which country/region you belong to. In your Yahoo Mail account, under Mail Options, click on POP Access and Forwarding and the precise Server Settings will be listed under POP Access Settings. For an India-based Yahoo Mail account (ending with ".in") the details are: Incoming Mail Server (POP3): in.pop.mail.yahoo.com Use SSL, port: 995 Outgoing Mail Server (SMTP): in.smtp.mail.yahoo.com Use SSL, port: 465, use authentication Code Sample Here protected void Button1_Click(object sender, EventArgs e) { MailMessage mail = new MailMessage(); mail.To.Add("[email protected]"); mail.To.Add("[email protected]"); mail.From = new MailAddress("[email protected]"); mail.Subject = "Email using Gmail"; string Body = "Hi, this mail is to test sending mail"+ "using Gmail in ASP.NET"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new System.Net.NetworkCredential ("[email protected]","YourGmailPassword"); //Or your Smtp Email ID and Password smtp.EnableSsl = true; smtp.Send(mail); } REfmore info
using Hotmail
paul daniel189 reputationPosted Feb 15, 2010, 1:09 AM EST
http://www.example-code.com/csharp/smtp_yahooSsl.asp
Kirtan PatelRank #292 · 8.6K reputationPosted Feb 15, 2010, 5:06 AM EST
yahoo Does not provide pop and SMTP facilities in normal account ..you need to purchase yahoo premium account to use POP and SMTP service so that its not working .
and Hot mail also dont work with smtp.. as it uses some web mail..instead of smtp..so that only Their developed mail client is working with it ..