Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SMTP电子邮件不起作用,5.7.1客户端没有作为此发件人发送的权限_C#_Email_Smtp_Gmail_Exchange Server - Fatal编程技术网

C# SMTP电子邮件不起作用,5.7.1客户端没有作为此发件人发送的权限

C# SMTP电子邮件不起作用,5.7.1客户端没有作为此发件人发送的权限,c#,email,smtp,gmail,exchange-server,C#,Email,Smtp,Gmail,Exchange Server,早上好,我不明白为什么这个代码不起作用!谢谢,等着瞧:) 看起来你需要在你的gmail帐户中启用pop3——查看gmail的帮助部分,了解如何在你的电子邮件程序中设置pop3的具体说明。如果您只想使用SMTP服务器,请跳过弹出位,只将SMTP设置为与您现有的电子邮件帐户一起使用。您花了很多时间设置SmtpClient,但却完全无法使用它。什么是SMTP?我们是想猜测吗?同时尝试设置UseDefaultCredentials=false;在Credentials=pass不起作用之前,我也更改了W

早上好,我不明白为什么这个代码不起作用!谢谢,等着瞧:)


看起来你需要在你的gmail帐户中启用pop3——查看gmail的帮助部分,了解如何在你的电子邮件程序中设置pop3的具体说明。如果您只想使用SMTP服务器,请跳过弹出位,只将SMTP设置为与您现有的电子邮件帐户一起使用。

您花了很多时间设置SmtpClient,但却完全无法使用它。什么是
SMTP
?我们是想猜测吗?同时尝试设置UseDefaultCredentials=false;在Credentials=pass不起作用之前,我也更改了Web.config,但在它运行时没有任何更改如果您使用exchange,则可能必须使用其他端口,并且exchange服务器必须支持smtp邮件发送
protected void Enviar_Click(object sender, EventArgs e)
    {


        var pass = new NetworkCredential();
        pass.UserName = "myuser@gmail.com";
        pass.Password = "password";


        var smtpClient = new SmtpClient();

        smtpClient.Port = 587;
        smtpClient.Host = "smtp.gmail.com";
        smtpClient.Credentials = pass;
        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtpClient.EnableSsl = true;
        smtpClient.UseDefaultCredentials = false;


        var email = new MailMessage(pass.UserName, "myname@mywork.com.br", txtsubject.Text,
                                    "name   :  " + txtname.Text + "menssage  : " + txtMessage.Text);

        SMTP.Enviar(email);
    }