Last post Feb 04, 2010 01:57 AM by chayadi
Feb 01, 2010 06:53 PM|flostin|LINK
Does anyone know how to add the ability to send an email as soon as an ad has been posted i.e. when the finish button has been clicked in PostAd.aspx?
Feb 01, 2010 07:57 PM|chayadi|LINK
Try this article: http://www.4guysfromrolla.com/articles/072606-1.aspx
Feb 03, 2010 05:03 PM|flostin|LINK
Thanks for your help. The article provides various ways of sending email but I was unable to get the info I wanted from it and looking back at my request for help I have not explained very clearly just what I am looking for.
I would like to send a confirmation email, to the poster of an ad, when they click on the finish/complete button in PostAd.aspx (classified starter kit). I need the email to be sent automatically to confirm that their posting has been received. I am a newbie
and am struggling to add the right code for this part. I managed to do it for the registration of a new member using the 'mail definition' that is available in 'create user' and had hoped their was a similarly easy approach for the posted ad section?
Any more ideas would be much appreciated.
Feb 04, 2010 01:57 AM|chayadi|LINK
I am not sure about classified starter kit.
But to send email on (let's say) button click event, you have to:
1. Set the smtp on web.config
<configuration> <!-- Add the email settings to the <system.net> element --> <system.net> <mailSettings> <smtp> <network host="relayServerHostname" port="portNumber" userName="username" password="password" /> </smtp> </mailSettings> </system.net> <system.web> ... </system.web></configuration>
2. On the button click event:
Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click
'!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
Const ToAddress As String = "firstname.lastname@example.org"
'(1) Create the MailMessage instance
Dim mm As New MailMessage(UsersEmail.Text, ToAddress)
'(2) Assign the MailMessage's properties
mm.Subject = Subject.Text
mm.Body = Body.Text
mm.IsBodyHtml = False
'(3) Create the SmtpClient object
Dim smtp As New SmtpClient
'(4) Send the MailMessage (will use the Web.config settings)
Actually the tutorial comes with a sample project.
You can download it and give it a try.
The mail definition is a feature from the login control,
but i dont think you can use it on this case.