Guest User

Untitled

a guest
Jul 21st, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. Public Sub SendMail(ByVal EmailFrom As String, ByVal FromName As String, ByVal ToName As String, ByVal EmailTo As String, ByVal MailSubject As String, ByVal MailBody As String, ByVal Bcc As Int32)
  2. Try
  3. Dim mail As New MailMessage()
  4. Dim smtp As New SmtpClient()
  5. mail.From = New MailAddress(EmailFrom, FromName)
  6. mail.To.Add(EmailTo)
  7. mail.Subject = MailSubject
  8. mail.Body = MailBody
  9.  
  10. mail.IsBodyHtml = True
  11. smtp.Host = "smtp.gmail.com"
  12. smtp.Credentials = New System.Net.NetworkCredential("example@gmail.com","abc")
  13. smtp.Send(mail)
  14. Catch ex As Exception
  15. End Try
  16. End Sub![enter image description here][1]
  17.  
  18. mail.To.Add(new MailAddress(EmailTo, ToName));
  19.  
  20. Are you using ASp.NET Membership?? If so, you can try this
  21.  
  22. using System.Web.Security;
  23.  
  24. MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name);
  25.  
  26. if (user != null)
  27. {
  28. string username = user.UserName;
  29. //set your label text here
  30. }
Add Comment
Please, Sign In to add comment