user1150440
user1150440

Reputation: 449

Proxy with smtp

Private Function SendEMail(ByVal sendTo As String, ByVal subject As String) As Boolean
        Try
            ''# Dim cr As New System.Net.NetworkCredential("me073055", "me271288")
            ''# Dim pr As New System.Net.WebProxy("172.31.100.25", 3128)
            ''# pr.Credentials = cr


            Dim mail As New MailMessage()
            mail.[To].Add(sendTo)

            ''# MsgBox(mail.[To].ToString)

            mail.From = New MailAddress(TextBoxFromAddress.Text, "NyxSolutions")
            mail.Subject = subject & " Automation System"
            ''#  MsgBox(mail.Subject)
            Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("", Nothing, "text/plain")
            Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:companylogo><br/><a href='http://www.nyxsolutions.in'>Click Here to visit our website</a><br/><a href='mailto:[email protected]'> Click Here to send us an email</a>", Nothing, "text/html")

            Dim logo As New LinkedResource(TextBoxSelectPicture.Text)
            logo.ContentId = "companylogo"
            htmlView.LinkedResources.Add(logo)

            mail.AlternateViews.Add(plainView)
            mail.AlternateViews.Add(htmlView)
            Dim Body As String = ""
            mail.Body = Body
            mail.Attachments.Add(New Attachment(TextBoxAttachment1.Text))
            ''# mail.Attachments.Add(New Attachment(TextBoxAttachment2.Text))
            ''# mail.Attachments.Add(New Attachment(TextBoxAttachment3.Text))

            mail.IsBodyHtml = True
            Dim smtp As New SmtpClient()
            smtp.Host = "smtp.gmail.com"
            smtp.Port = 25
            smtp.UseDefaultCredentials = True
            smtp.Credentials = New System.Net.NetworkCredential(TextBoxFromAddress.Text, "vinson24")
            smtp.EnableSsl = True
            smtp.Send(mail)
            ''# MsgBox("Sent")
        Catch ex As SmtpException
            MsgBox(ex.Message)
        End Try
    End Function

I am using the given code to send emails ...i am behind a proxy server..is there any way to give the proxy settings to the smtp client??If not then how do i send emails from behind a proxy server..??

These are the settings i need to use to connect to the internet...i need to set this settings in my email client also.

enter image description here

Upvotes: 2

Views: 2710

Answers (1)

Frank Tudor
Frank Tudor

Reputation: 4504

there is a package I once used for things like this called squid proxy. It was very useful to me.

http://squid-web-proxy-cache.1019090.n4.nabble.com/Can-squid-be-configured-as-SMTP-SMTPS-proxy-td2727188.html

http://www.squid-cache.org/

I hope this helps.

Upvotes: 1

Related Questions