如何使用VB.NET发送没有密码的邮件 [英] How do I send mails without password using VB.NET

查看:136
本文介绍了如何使用VB.NET发送没有密码的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...





我有一个vb.net控制台应用程序,它在许多客户端站点上运行以发送电子邮件。所有客户端都提供了电子邮件ID,服务器名称,端口和密码。

但是这个客户端说他们没有任何电子邮件密码。他们在没有密码的情况下使用他们的邮件。



我尝试使用谷歌的代码发送没有密码的电子邮件,这与我的公司邮件ID一起使用。但仍然,在客户端它抛出错误。





Hi...


I have one vb.net console application which is running on many client sites for sending an email. All client provided email id, server name, port, and password.
but this client is saying that they don't have any password for emails. they are using their mail without a password.

I tried with a code from google to send email without a password, which is working with my companies mail id. but still, in client side it throwing an error.


the smtp server requires a secure connection or the client was not authenticated 5.7 57





我尝试过:





What I have tried:

Try
            ServicePointManager.ServerCertificateValidationCallback = _
        New System.Net.Security.RemoteCertificateValidationCallback(AddressOf customCertValidation)

            Dim Smtp_Server As New SmtpClient
            Dim mailobj As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            If rbtnWithPass.Checked = True Then
                Smtp_Server.Credentials = New Net.NetworkCredential(txtFrom.Text.Trim, txtPassword.Text.Trim)
                mailobj.Subject = "Test mail with password"
            Else
                Smtp_Server.Credentials = System.Net.CredentialCache.DefaultCredentials
                mailobj.Subject = "Test mail without password"
            End If


            Smtp_Server.Port = txtPort.Text.Trim
            Smtp_Server.EnableSsl = False
            If rbtnServer.Checked = True Then
                Smtp_Server.Host = txtServerName.Text.Trim
            Else
                Smtp_Server.Host = txtServerIP.Text.Trim
            End If

            mailobj = New MailMessage()
            mailobj.From = New MailAddress(txtFrom.Text.Trim)
            Dim toArr As String()
            toArr = txtTo.Text.Trim.Split(",")
            For Each toStr As String In toArr
                Dim val As String = toStr.Replace(vbLf, "")
                mailobj.[To].Add(val)
            Next
            Dim ccArr As String()
            ccArr = txtTo.Text.Trim.Split(",")
            For Each ccStr As String In ccArr
                Dim val As String = ccStr.Replace(vbLf, "")
                mailobj.CC.Add(New Net.Mail.MailAddress(val))
            Next
            mailobj.Body = txtBody.Text.Trim + vbLf + vbLf            

            Smtp_Server.Send(mailobj)

            MsgBox("Email send successfully. From:" & txtFrom.Text.Trim & " To: " & txtTo.Text.Trim & " Time : " & Now)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try










Private Function customCertValidation(ByVal sender As Object, _
                                              ByVal cert As X509Certificate, _
                                              ByVal chain As X509Chain, _
                                              ByVal errors As Net.Security.SslPolicyErrors) As Boolean

        Return True

推荐答案

嗯...你不明白这条消息的哪一部分?



Ummm... What part of this message do you not understand?

引用:

smtp服务器需要安全连接或客户端未经过身份验证

the smtp server requires a secure connection or the client was not authenticated



正在使用的服务器需要用户名和密码或其他经过身份验证/安全连接发送电子邮件。



无法在没有密码的情况下在任何服务器上发送电子邮件。


The server being used REQUIRES a username and password or otherwise authenticated/secured connection to send an email.

Sending an email on whatever server they're using without a password is not an option.


这篇关于如何使用VB.NET发送没有密码的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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