我遇到了 Google IMAP 的问题

I Am Facing an Issue with Google IMAPs

提问人:Amir 提问时间:12/13/2022 更新时间:12/13/2022 访问量:18

问:

我正在做一个能够发送电子邮件的项目,但是,发送电子邮件的主要功能面临一些问题,我在我的编码和我的同事之间做了一些交叉引用,发现它们匹配,但是我仍然无法发送上述电子邮件。

我尝试在网上查找并应用了他们的解决方案,但尚未解决。是我的编码有问题还是我设置的 SMTP 服务器?

Imports System.Net.MailImports System.IOImports System.DataImports System.Data.OdbcImports System.Web.UI.PagePartial Class _DefaultInherits System.Web.UI.Page
Private Sub Button_Redirect_Click(sender As Object, e As EventArgs) Handles Button_Redirect.Click
    Response.Redirect("excel_upload.aspx")
End Sub

Private Sub submit_Click(sender As Object, e As EventArgs) Handles submit.Click
    Response.Write(tmail.Text)
    Response.Write("<br>")
    Response.Write(fmail.Text)
    Response.Write("<br>")
    Response.Write(customerRequest.Text)
    Response.Write(kin.Text)
    Response.Write("<br>")
    Response.Write(kul.Text)
    Response.Write("<br>")
    Response.Write(icpsp.Text)
    Response.Write("<br>")
    Response.Write(fname.Text)
    Response.Write("<br>")
End Sub

Function SendEmail() As Boolean
    Dim SmtpServer As New SmtpClient()
    Dim mail As New MailMessage()
    Dim msg As String = ""

    Try
        SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "nxbciglfckwinxiz")
        SmtpServer.Host = "smtp.gmail.com"
        SmtpServer.Port = 143
        SmtpServer.EnableSsl = True

        mail = New MailMessage()
        mail.From = New MailAddress(fmail.Text)
        mail.To.Add(tmail.Text)
        mail.Bcc.Add("")
        'mail.Subject = "Permohonan Pengaktifan ePayment@USM"
        mail.IsBodyHtml = True
        mail.Body = customerRequest.Text

        'If FileLoc <> "" Then
        '    If File.Exists(FileLoc) Then mail.Attachments.Add(New Attachment(FileLoc))
        'End If

        mail.Priority = MailPriority.High
        SmtpServer.Send(mail)

        msg = "Emel telah dihantar."
        Return True
    Catch ex As SmtpFailedRecipientsException
        For i As Integer = 0 To ex.InnerExceptions.Length - 1
            Dim status As SmtpStatusCode = ex.InnerExceptions(i).StatusCode

            If status = SmtpStatusCode.MailboxBusy OrElse status = SmtpStatusCode.MailboxUnavailable Then
                msg = "Delivery failed - retrying in 5 seconds."
                System.Threading.Thread.Sleep(5000)
                SmtpServer.Send(mail)
            Else
                msg = "Failed to deliver message to {0}" + ex.InnerExceptions(i).FailedRecipient
            End If
        Next
    Catch ex As Exception
        msg = "Exception caught in RetryIfBusy(): {0}" + ex.ToString()
    End Try

    Return False
End Function

网站布局的图像

IMAP 设置的图像

我更改了 SMTP 服务器主机和端口。 我设置了一个新的 Windows MAIL IMAP 帐户。

asp.net 电子邮件 smtp gmail-imap

评论


答: 暂无答案