从发送邮件的地址未显示在recepeint收件箱中

从发送邮件的地址未显示在recepeint收件箱中

本文介绍了从发送邮件的地址未显示在recepeint收件箱中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void btnSubmit_Click(object sender, EventArgs e)
{
    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 = txtEmail.Text;
        Msg.Body = "NAME : " + txtName.Text + "EMAIL : " + txtEmail.Text + " SUBJECT : " + txtSubject.Text + "MESSAGE: " + txtMessage.Text;
        Msg.IsBodyHtml = true;
        // your remote SMTP server IP.
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.live.com"; 
        smtp.Port = 587;
        Msg.Priority = MailPriority.Normal;
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "SolaiMail");
        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 = "";
    }
    catch (Exception ex)
    {
        Console.WriteLine("{0} Exception caught.", ex.ToString());
    }

推荐答案


这篇关于从发送邮件的地址未显示在recepeint收件箱中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 14:41