Email Sending in ASp.NET as per user needs
-
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
-
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
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
-
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
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
-
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
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