如何发送没有发件人密码的电子邮件用于反馈表单

如何发送没有发件人密码的电子邮件用于反馈表单

本文介绍了如何发送没有发件人密码的电子邮件用于反馈表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string name = txt_name.Text;
        string emailfrom = txt_email.Text;
        string subject = txt_subject.Text;
        string ddl_email = DropDownList1.Text;
        string msg = txt_message.Text;
        //string emailid;
        SmtpClient client = new SmtpClient();


        // NetworkCredential loginInfo = new NetworkCredential(emailto, emailpassword);
        MailMessage message = new MailMessage();
        message.From = new MailAddress(emailfrom + '@' + ddl_email, name);
        message.To.Add(new MailAddress("[email protected]", "name"));
        NetworkCredential cs = new NetworkCredential("[email protected]", "xyz");
        if (ddl_email == "gmail.com")
        {
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.EnableSsl = true;
        }
        else if (ddl_email == "yahoo.com")
        {
            client.Host = "smtp.mail.yahoo.com";
            client.Port = 587;
            client.EnableSsl = false;
        }
        else
        {
            client.Host = "smtp.live.com";
            client.Port = 587;
            client.EnableSsl = false;
        }
        message.Subject = subject;
        message.Body = msg;
        message.IsBodyHtml = true;

        client.UseDefaultCredentials = true;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.Credentials = cs;
        client.Send(message);

推荐答案



这篇关于如何发送没有发件人密码的电子邮件用于反馈表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:41