Email TimeOut is occuing when sending emails from MS Outlook (VB .NET)

Hello Aspose team,

My team recently purchased Aspose Total license and began using Email functionalities in VB.NET. Sending between gmails has worked instantaneously but sending between Outlook resulted in timeout issue.

Heres the simple code snippet that we’re using in testing out Outlook email:

    Public Shared Sub Send(oEmail As clsObject)
        Try
            oEmail.Props(EMAIL_SENT).SetProperty(False)
            ' Instantiate an instance of license and set th elicense file through its path
            Dim AsposeLicense As License = New License()

            AsposeLicense.SetLicense("Aspose.Total.lic")

            ' Email clsObjProp values
            Dim UserName As String = oEmail.Props(Email.USERNAME).Value
            Dim Password As String = oEmail.Props(Email.PASSWORD).Value
            Dim OutgoingServerName As String = oEmail.Props(OUTGOING_SERVER_NAME).Value
            Dim OutgoingServerPort As Integer = oEmail.Props(OUTGOING_SERVER_PORT).Value
            Dim UseHTML As Boolean = oEmail.Props(USE_HTML).Value
            Dim From As String = oEmail.Props(Email.FROM).Value
            Dim SendTo As String = oEmail.Props(SEND_TO).Value
            Dim CC As String = oEmail.Props(Email.CC).Value
            Dim BCC As String = oEmail.Props(Email.BCC).Value
            Dim Subject As String = oEmail.Props(Email.SUBJECT).Value
            Dim BodyText As String = oEmail.Props(BODY_TEXT).Value
            Dim Attachment As String = oEmail.Props(ATTACHMENTS).Value
            Dim UseSSL As Boolean = oEmail.Props(SSL).Value
            Dim Enabled As Boolean = oEmail.Props(Email.ENABLED).Value
            Dim BeforeSend As String = oEmail.Props(BEFORE_SEND).Value
            Dim AfterSend As String = oEmail.Props(AFTER_SEND).Value

            If Enabled Then

                ' BeforeSend QuickScript
                If BeforeSend.Count > 0 Then
                    Script.RunQuickScript(oEmail.Props(BEFORE_SEND).Key, {})
                End If

                ' Setting up Smtp Client
                Dim Client As New SmtpClient()

                ' Validating user inputs
                If UserName = "" Or Password = "" Then
                    oEmail.Props(ERROR_MESSAGE).SetProperty("Must have valid Username and password.")
                    oEmail.Props(EMAIL_SENT).SetProperty(False)
                    Exit Sub
                End If

                If OutgoingServerName = "" Or OutgoingServerPort.ToString() = "" Then
                    oEmail.Props(ERROR_MESSAGE).SetProperty("Must have valid server port# and outgoing server name.")
                    oEmail.Props(EMAIL_SENT).SetProperty(False)
                    Exit Sub
                End If

                ' Specifying mailing host server, username, password, port and security options
                Client.Host = OutgoingServerName
                Client.Username = UserName
                Client.Password = Password
                Client.Port = OutgoingServerPort
                Client.SecurityOptions = If(UseSSL, SecurityOptions.SSLExplicit, SecurityOptions.None)

                ' Setting up message
                Dim Message As New MailMessage With {
                    .From = From,
                    .Subject = Subject
                }

                ' Determining email format (html or plain text)
                If UseHTML Then
                    Message.HtmlBody = BodyText
                Else
                    Message.Body = BodyText
                End If


                ' Storing email addresses and attachments separated by the comma
                Dim Tos As String() = SendTo.Split(";")
                Dim CCs As String() = CC.Split(";")
                Dim BCCs As String() = BCC.Split(";")
                Dim Attachments As String() = Attachment.Split(";")

                ' To recipients
                If Tos(0) = "" Then
                    oEmail.Props(ERROR_MESSAGE).SetProperty("Must have To recipient(s).")
                    oEmail.Props(EMAIL_SENT).SetProperty(False)
                    Exit Sub
                Else

                    ' Adding multiple To's recipients
                    For Each SendingTo As String In Tos
                        Message.To.Add(SendingTo)
                    Next

                End If

                ' CC recipients
                ' Adding multiple CC's recipients
                If CCs(0) <> "" Then
                    For Each SendingCC As String In CCs
                        Message.CC.Add(SendingCC)
                    Next
                End If


                ' BCC recipients
                ' Adding multiple BCC's recipients
                If BCCs(0) <> "" Then
                    For Each SendingBCC As String In BCCs
                        Message.Bcc.Add(SendingBCC)
                    Next
                End If


                ' Attachments
                ' Adding multiple attachments to recipients
                If Attachments(0) <> "" Then
                    For Each SendingAttachment As String In Attachments
                        Message.Attachments.Add(New Attachment(SendingAttachment))
                    Next
                End If

                ' Sending email
                Client.Send(Message)

                ' Updating status that it got successfully sent to all recipients
                oEmail.Props(EMAIL_SENT).SetProperty(True)
                oEmail.Props(ERROR_MESSAGE).SetProperty("")

                ' AfterSend QuickScript
                If AfterSend.Count > 0 Then
                    Script.RunQuickScript(oEmail.Props(AFTER_SEND).Key, {})
                End If

                'Disconnect from SMTP
                Client.Dispose()
            Else

                oEmail.Props(ERROR_MESSAGE).SetProperty("Email object must be enabled to send email.")

            End If

        Catch ex As Exception

            ' Updating status that it failed to send email to the recipients
            oEmail.Props(EMAIL_SENT).SetProperty(False)
            oEmail.Props(ERROR_MESSAGE).SetProperty(ex.Message)
            LogMessage($"Error while executing Email object's Sub 'Send', Message: {ex.Message}", True)

        End Try
    End Sub

Please let me know why it causes timeout error only with Outlook emails?

@cpcx,

Can you please share source email along with version details which you are using on your end.

I am sending to cpcx@aschome.com - I am using Microsoft Office 365 ProPlus - outlook version 1910 (build 12130.20272).

Aspose Email 19.10

@cpcx,

Can you please share test account credential to reproduce issue on our end so that we may help you out.

Hello Adnan,

I sent credential through private message a week ago, maybe you did not get it from me. Here is the test account credential.

Email: CPCx@aschome.com

Password: Cx!23456

@cpcx,

Thank you for sharing the information with us. I have tried using the sample code shared by you. Unfortunately, I am unable to use the sample code as it contains reference to undeclared variables. Can you please provide the working sample project that we may test on our end to help you. We really appreciate your cooperation in this regard.