Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 2.01 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Proxy with smtp
  2. Private Function SendEMail(ByVal sendTo As String, ByVal subject As String) As Boolean
  3.         Try
  4.             ''# Dim cr As New System.Net.NetworkCredential("me073055", "me271288")
  5.             ''# Dim pr As New System.Net.WebProxy("172.31.100.25", 3128)
  6.             ''# pr.Credentials = cr
  7.  
  8.  
  9.             Dim mail As New MailMessage()
  10.             mail.[To].Add(sendTo)
  11.  
  12.             ''# MsgBox(mail.[To].ToString)
  13.  
  14.             mail.From = New MailAddress(TextBoxFromAddress.Text, "NyxSolutions")
  15.             mail.Subject = subject & " Automation System"
  16.             ''#  MsgBox(mail.Subject)
  17.             Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("", Nothing, "text/plain")
  18.             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:info@nyxsolutions.in'> Click Here to send us an email</a>", Nothing, "text/html")
  19.  
  20.             Dim logo As New LinkedResource(TextBoxSelectPicture.Text)
  21.             logo.ContentId = "companylogo"
  22.             htmlView.LinkedResources.Add(logo)
  23.  
  24.             mail.AlternateViews.Add(plainView)
  25.             mail.AlternateViews.Add(htmlView)
  26.             Dim Body As String = ""
  27.             mail.Body = Body
  28.             mail.Attachments.Add(New Attachment(TextBoxAttachment1.Text))
  29.             ''# mail.Attachments.Add(New Attachment(TextBoxAttachment2.Text))
  30.             ''# mail.Attachments.Add(New Attachment(TextBoxAttachment3.Text))
  31.  
  32.             mail.IsBodyHtml = True
  33.             Dim smtp As New SmtpClient()
  34.             smtp.Host = "smtp.gmail.com"
  35.             smtp.Port = 25
  36.             smtp.UseDefaultCredentials = True
  37.             smtp.Credentials = New System.Net.NetworkCredential(TextBoxFromAddress.Text, "vinson24")
  38.             smtp.EnableSsl = True
  39.             smtp.Send(mail)
  40.             ''# MsgBox("Sent")
  41.         Catch ex As SmtpException
  42.             MsgBox(ex.Message)
  43.         End Try
  44.     End Function