如何使用Hotmail或asp.net中的任何邮件SMTP服务器发送邮件 [英] How to send mail using Hotmail or any mail SMTP server in asp.net

查看:101
本文介绍了如何使用Hotmail或asp.net中的任何邮件SMTP服务器发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Hotmail或任何邮件SMTP邮件服务器发送邮件。

请帮助我。

I want to send mail using hotmail or any mail SMTP mail server.
Please help me.

推荐答案

Hi Niraj,< br $> b $ b

希望这个链接更有帮助链接 [ ^ ]



问候,

RK
Hi Niraj,

Hope this link would be more helpful link[^]

Regards,
RK


Hi


你可以尝试这段代码,它曾经为我工作过。



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

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...


//向HOTMAIL发送电子邮件的方法

//method to send email to HOTMAIL
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
       }





谢谢&注意

Sham:)



Thanks & Regard
Sham :)


这篇关于如何使用Hotmail或asp.net中的任何邮件SMTP服务器发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆