Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment