Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2008 Sending e-mail

$
0
0
Hello,

Let me first say that I searched the forums for a solution, but no matter what I try it's always the same. No error, no e-mail.

Below is a sub I use to send e-mail. It executes without any errors, but I never get the e-mail.

Is there something I'm missing here?

vb.net Code:
  1. Private Sub labelaKliknuta(ByVal sender As DevExpress.XtraEditors.HyperLinkEdit, ByVal e As System.EventArgs)
  2.         If sender.Tag <> "" Then
  3.             If MessageBox.Show("Da li ste sigurni da želite poslati rođendansku čestitku studentu: " & vbNewLine & sender.Text & "", "Potvrda", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
  4.  
  5.                 Dim MyMailMessage As New MailMessage()
  6.  
  7.                 Try
  8.                     MyMailMessage.From = New MailAddress("someaddress@something")
  9.                     MyMailMessage.To.Add(sender.Tag.ToString)
  10.                     MyMailMessage.Subject = "Sretan rođendan!"
  11.                     MyMailMessage.Body = "Poštovani kolega " & sender.Text & "," & vbNewLine & "Želimo Vam mnogo sreće i veselja za Vaš rođendan!" & vbNewLine & "Vaš, Team."
  12.  
  13.                     Dim SMTP As New SmtpClient("smtp.googlemail.com")
  14.                     SMTP.EnableSsl = True
  15.                     SMTP.Port = 465
  16.                     SMTP.Credentials = New System.Net.NetworkCredential("username", "password")
  17.                     SMTP.SendAsync(MyMailMessage, Nothing)
  18.                     MessageBox.Show("Poslano")
  19.                 Catch ex As Exception
  20.                     MessageBox.Show("Greska")
  21.                 End Try
  22.  
  23.  
  24.  
  25.             End If
  26.         Else
  27.             MessageBox.Show("Za odabranog studenta ne postoji podatak o e-mail adresi u sistemu" & vbNewLine & "Molimo kontaktirajte administratora kako bi se problem riješio", "Nedostaje e-mail adresa", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
  28.  
  29.         End If
  30.  
  31.     End Sub

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>