jcraun
asked on
Open Default Email and populate Message with Text from VB.NET
Hi Experts!
I need a button in an ASP.NET web app that when clicked will open the users default mail application and populate the body of the email message with text from the current webform.. anydirection on how do do this will be greatly appreciated
thanks ;)
I need a button in an ASP.NET web app that when clicked will open the users default mail application and populate the body of the email message with text from the current webform.. anydirection on how do do this will be greatly appreciated
thanks ;)
ASKER
Neat thanks!.. okay... so what if I need the body of the message to be a concatention of the input of several textboxes from the form that the send email button is on?
In this case instead of
...body=bla bla bla';"
use
...body=" & txt1.text & " " & txt2.text & "';"
...body=bla bla bla';"
use
...body=" & txt1.text & " " & txt2.text & "';"
ASKER
Okay getting closer.... Only problem is:
1. how do you format the body?
I tried
body=" & txt1.text & " <br> " & txt2.text & "';"
and I got: bob <br> nancy
instead of:
bob
nancy
2. Is there any way to get this to work when it is not in the Page Load event because the user needs to fill out the form/textboxes and then submit the email..
Thanks for your patience!
1. how do you format the body?
I tried
body=" & txt1.text & " <br> " & txt2.text & "';"
and I got: bob <br> nancy
instead of:
bob
nancy
2. Is there any way to get this to work when it is not in the Page Load event because the user needs to fill out the form/textboxes and then submit the email..
Thanks for your patience!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I could eventually make that way work but I am not very familiar w/JS and I need a lot of formatting in the email such as bold, and line breaks etc... and these are long emails.....
here is and example of the way I have been sending emails.. but if I could just make it Display rather than send would be my best option. Do you know how to do it this way? Or what I would have to add?
************************** ********** ********** ********** ********** ********** ********** ****
Dim genfunc As New GeneralFunctions()
Dim name As String
name = genfunc.GetFname(ddlOwner. SelectedIt em.ToStrin g)
strEmailrecip = genfunc.GetEmail(strOwner)
'send an email when message is submitted
Dim mailMessage As System.Web.Mail.MailMessag e = New System.Web.Mail.MailMessag e()
mailMessage.From = "do_not_reply@test.com"
mailMessage.To = strEmailrecip
mailMessage.Subject = "New Crit_Sit Task submitted"
mailMessage.BodyFormat = System.Web.Mail.MailFormat .Html
mailMessage.Body = "<font face=arial size=2>"
mailMessage.Body &= strMessage & "<br><br><br>"
mailMessage.Body &= strMessage1 & "<br>"
mailMessage.Body &= "<b>" + "Task Description:" + "</b>" + "<br>"
mailMessage.Body &= txtTaskDescription.Text + "<br>"
mailMessage.Body &= "<b>" + "Due Date:" + "</b>" + "<br>"
System.Web.Mail.SmtpMail.S mtpServer = "test.test.com"
System.Web.Mail.SmtpMail.S end(mailMe ssage)
here is and example of the way I have been sending emails.. but if I could just make it Display rather than send would be my best option. Do you know how to do it this way? Or what I would have to add?
**************************
Dim genfunc As New GeneralFunctions()
Dim name As String
name = genfunc.GetFname(ddlOwner.
strEmailrecip = genfunc.GetEmail(strOwner)
'send an email when message is submitted
Dim mailMessage As System.Web.Mail.MailMessag
mailMessage.From = "do_not_reply@test.com"
mailMessage.To = strEmailrecip
mailMessage.Subject = "New Crit_Sit Task submitted"
mailMessage.BodyFormat = System.Web.Mail.MailFormat
mailMessage.Body = "<font face=arial size=2>"
mailMessage.Body &= strMessage & "<br><br><br>"
mailMessage.Body &= strMessage1 & "<br>"
mailMessage.Body &= "<b>" + "Task Description:" + "</b>" + "<br>"
mailMessage.Body &= txtTaskDescription.Text + "<br>"
mailMessage.Body &= "<b>" + "Due Date:" + "</b>" + "<br>"
System.Web.Mail.SmtpMail.S
System.Web.Mail.SmtpMail.S
WHat you are doing is absolutely different from what you asked. YOur code sends SMTP email, that runs as Default SMTP server on your server. Server will be sending email, not a client
You asked to open the default email client on th eclient machine
Both approaches are good and you have to decide which one you prefer
You asked to open the default email client on th eclient machine
Both approaches are good and you have to decide which one you prefer
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.Button1.Text = "Send Mail"
Me.Button1.Attributes("onC
"window.location='mailto:b
End If
End Sub