Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Email Sending in ASp.NET as per user needs

Email Sending in ASp.NET as per user needs

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpasp-netdatabase
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    k_bhawna
    wrote on last edited by
    #1

    I need to send an email in ASP.NET using VB.NET as a language. This email sending format has to be actually according to my requirements which are: As there are different properties of mailMessage Object like From, To, CC, BCC, Subject, BODY and now the requirement is that i want to add controls in the Body property. Controls like Label, TextBox and other. Now these Controls will be databound as they will be fetching the values from the database. Now can anyone tell me, is there any way to actually put or include controls in the Body property of MailMessage object or any other way. I dont know how to do this. Please i request to guide. Thanking in advance

    J 1 Reply Last reply
    0
    • K k_bhawna

      I need to send an email in ASP.NET using VB.NET as a language. This email sending format has to be actually according to my requirements which are: As there are different properties of mailMessage Object like From, To, CC, BCC, Subject, BODY and now the requirement is that i want to add controls in the Body property. Controls like Label, TextBox and other. Now these Controls will be databound as they will be fetching the values from the database. Now can anyone tell me, is there any way to actually put or include controls in the Body property of MailMessage object or any other way. I dont know how to do this. Please i request to guide. Thanking in advance

      J Offline
      J Offline
      Jax_qqq
      wrote on last edited by
      #2

      Hiii, i have done the in my previous project... Use html tags in your body part...like objMsg.Body = "<-H1>This is an test mail<-/H1><-BR>this is an text box <-BR>Thanx<-BR>Anuj" i have use - o/w these tags will get activate...just remove this in your code. Thanx Anuj Kamthan Software Developer Solversa Technologies, Pune - 411007, India. http://www.solversa.com -- modified at 6:07 Monday 22nd May, 2006

      K 1 Reply Last reply
      0
      • J Jax_qqq

        Hiii, i have done the in my previous project... Use html tags in your body part...like objMsg.Body = "<-H1>This is an test mail<-/H1><-BR>this is an text box <-BR>Thanx<-BR>Anuj" i have use - o/w these tags will get activate...just remove this in your code. Thanx Anuj Kamthan Software Developer Solversa Technologies, Pune - 411007, India. http://www.solversa.com -- modified at 6:07 Monday 22nd May, 2006

        K Offline
        K Offline
        k_bhawna
        wrote on last edited by
        #3

        Hi, I tried ur suggestion , but i am not able to do it. Its not happening. Actually i have used: and has made a Function SendEmail whose code is: Protected Sub SendEmail(ByVal sender As Object, ByVal e As EventArgs) If IsValid = False Then Exit Sub End If Dim mail As New MailMessage() Dim stringArr As String() = GetData() mail.To = Request.Form("to") mail.From = Request.Form("from") If Request.Form("format").Equals("text") Then mail.BodyFormat = MailFormat.Text Else mail.BodyFormat = MailFormat.Html End If Dim i As Integer Dim buffer As New StringBuilder() For i = 0 To stringArr.Length - 1 If i <> 0 Then buffer.Append(";") End If buffer.Append(stringArr(i)) Next mail.Bcc = buffer.ToString() mail.Subject = Request.Form("subject") mail.Body = Request.Form("body") Try SmtpMail.SmtpServer = "127.0.0.1" SmtpMail.Send(mail) Catch ex As Exception message.Text = "<span style=""color:red;"">" & _ ex.Message & "</span>" Exit Sub End Try message.Text = "Message Sent...<br><br><a " & _ "href=""email.aspx"">Go Back</a>" End Sub Protected Function GetData() As String() Dim stringArr(3) As String stringArr(0) = "a@yahoo.com" stringArr(1) = "b@rediffmail.com" stringArr(2) = "c@yahoo.com" Return stringArr End Function This is working fine. Through this code i am able to send a simple mail. Please if you can tell what code u used, then it would be of help to me. Thanking You for ur time. Bhawna

        J 1 Reply Last reply
        0
        • K k_bhawna

          Hi, I tried ur suggestion , but i am not able to do it. Its not happening. Actually i have used: and has made a Function SendEmail whose code is: Protected Sub SendEmail(ByVal sender As Object, ByVal e As EventArgs) If IsValid = False Then Exit Sub End If Dim mail As New MailMessage() Dim stringArr As String() = GetData() mail.To = Request.Form("to") mail.From = Request.Form("from") If Request.Form("format").Equals("text") Then mail.BodyFormat = MailFormat.Text Else mail.BodyFormat = MailFormat.Html End If Dim i As Integer Dim buffer As New StringBuilder() For i = 0 To stringArr.Length - 1 If i <> 0 Then buffer.Append(";") End If buffer.Append(stringArr(i)) Next mail.Bcc = buffer.ToString() mail.Subject = Request.Form("subject") mail.Body = Request.Form("body") Try SmtpMail.SmtpServer = "127.0.0.1" SmtpMail.Send(mail) Catch ex As Exception message.Text = "<span style=""color:red;"">" & _ ex.Message & "</span>" Exit Sub End Try message.Text = "Message Sent...<br><br><a " & _ "href=""email.aspx"">Go Back</a>" End Sub Protected Function GetData() As String() Dim stringArr(3) As String stringArr(0) = "a@yahoo.com" stringArr(1) = "b@rediffmail.com" stringArr(2) = "c@yahoo.com" Return stringArr End Function This is working fine. Through this code i am able to send a simple mail. Please if you can tell what code u used, then it would be of help to me. Thanking You for ur time. Bhawna

          J Offline
          J Offline
          Jax_qqq
          wrote on last edited by
          #4

          Hii Bhawna Have u set this property... MailMessage mm = new MailMessage(); mm.BodyFormat = MailFormat.Html; Actually i m not able to understand your code in writen in vb... but what ever i understand i think it's right...and it should work.. try with this property...and let me know... Anuj

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups