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 MPosted Feb 10, 2010, 7:47 AM
http://forums.asp.net/p/1472620/3414566.aspx
charles heningtonPosted May 4, 2010, 3:51 AM
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
Kirtan PatelPosted Feb 15, 2010, 10:06 AM
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 ..
paul danielPosted Feb 15, 2010, 6:09 AM
http://www.example-code.com/csharp/smtp_yahooSsl.asp
Lalit MPosted Feb 10, 2010, 11:44 PM