本文介绍了发送电子邮件不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



以下是我使用我的服务器发送电子邮件的代码。但它会引发异常。

Hi friends,

the following is my code for sending email using my server.but it throws an exception.

try
        {
            MailMessage Msg = new MailMessage();
            // Sender e-mail address.
            Msg.From = new MailAddress(txtEmail.Text);
            // Recipient e-mail address.
            Msg.To.Add("[email protected]");
            Msg.Subject = txtSubject.Text;
            Msg.Body = txtMessage.Text;
            Msg.IsBodyHtml = true;
            // your remote SMTP server IP.
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "mail.dhuvara.com";
            smtp.Port = 25;
            Msg.Priority = MailPriority.Normal;
            smtp.Credentials = new System.Net.NetworkCredential("xxxxxx", "xxxxx");
            smtp.EnableSsl = true;
            smtp.Send(Msg);
            //Msg = null;
            lbltxt.Text = "Thanks for Contact us";
            // Clear the textbox valuess
            txtName.Text = "";
            txtSubject.Text = "";
            txtMessage.Text = "";
            txtEmail.Text = "";







和smtp异常是:无法发送邮件




and the smtp exception is : "failure to send mail"

推荐答案

smtp.Host = "mail.dhuvara.com";





而是使用:



but instead use:

smtp.Host = "smtp.live.com";





smtp.live.com是用于Outlook.com帐户的smtp服务器。



Valery。



smtp.live.com is the smtp server to use for Outlook.com accounts.

Valery.


这篇关于发送电子邮件不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:33