Click here to Skip to main content
15,123,923 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to send mail using hotmail or any mail SMTP mail server.
Please help me.
Posted
Comments
[no name] 22-Aug-13 9:06am
   
Help you with what? If that is what you want to do, then do it.

Hi Niraj,

Hope this link would be more helpful link[^]

Regards,
RK
   
Hi
you can try this code, it once worked for me.

C#
private void button4_Click(object sender, RoutedEventArgs e)
        {


            MailMessage message = new MailMessage();

            message.From = new MailAddress("name@hotmail.com");
            message.To.Add(new MailAddress("recipient@gmail.com"));
            message.Subject = subject.Text;
            message.Body = body.Text;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("name@hotmail.com", "pswd");

            client.Port = 25;
            client.Host = "smtp.live.com";
            client.EnableSsl = true;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }


        }


vote if it helps...
   
//method to send email to HOTMAIL
C#
public void SendEMailThroughHotMail()
       {
           try
           {
               //Mail Message
               MailMessage mM = new MailMessage();
               //Mail Address
               mM.From = new MailAddress(txtUserName.Text);
               //receiver email id
               mM.To.Add(txtTo.Text);
               //subject of the email
               mM.Subject = txtSubject.Text;
               //deciding for the attachment
               mM.Attachments.Add(new Attachment(@FilePath));
               //add the body of the email
               mM.Body = richTextBox1.Text;
               mM.IsBodyHtml = true;
               //SMTP client
               SmtpClient sC = new SmtpClient("smtp.live.com");
               //port number for Hot mail
               sC.Port = 25;
               //credentials to login in to hotmail account
               sC.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text);
               //enabled SSL
               sC.EnableSsl = true;
               //Send an email
               sC.Send(mM);
           }//end of try block
           catch (Exception Ex)
           {
               MessageBox.Show(Ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
           }//end of catch
       }


Thanks & Regard
Sham :)
   
For sending firstly add packages on your code:
C#
using System.Web.Services;
using System.Net.Mail;


After that create method of sending mail:

public static void SendMail(string from, string to, string bcc, string cc, string subject, string body)
{
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress(from);
mMailMessage.To.Add(new MailAddress(to));

if ((bcc != null) && (bcc != string.Empty))
{
mMailMessage.Bcc.Add(new MailAddress(bcc));
}

if ((cc != null) && (cc != string.Empty))
{
mMailMessage.CC.Add(new MailAddress(cc));
}

mMailMessage.Subject = subject;
mMailMessage.Body = body;
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Send(mMailMessage);
}
   

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