Click here to Skip to main content
15,896,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is there a way to send an email automatically to a customer through VB.NET code?

Thanks,

My name is Jean-Sébastien Vachon
Posted

Jean-Sébastien Vachon wrote:
send an email automatically

What is automatically? There has to be some event or some service associated with your application.

Here[^] you'll find code for sending email.

Also, see this[^]
 
Share this answer
 
Jean-Sébastien Vachon wrote:
email automatically to a customer


I assume by automatically you mean no manual steps involved but some trigger event!

You can use Windows Service to do it for you. lets say every week at 12 on Monday Night, email some data to customer.
So in windows service, make it active when needed, ping DB, get data, check the conditions if any, send across the email.

BTW, a simple Google would had given you all that you need some sort of Scheduling Service to do that for you!
 
Share this answer
 
Yes

Inside of the web.config file you need to set up the system.net settings.

<system.net>
     <mailSettings>
	<smtp>
	   <network host="smtp.yourProvider.com" port="25" userName="support@yourSite.com" password="yourPassword"/>
	</smtp>
     </mailSettings>
</system.net>


In the behind code

Dim message As New System.Net.Mail.MailMessage("support@yourSite.com", "personsEmail@emailProvider.com")

 message.Subject = "New Ticket"
 message.Body = TextBox1.Text.ToString

 Try
    smtp.Send(message)
Catch ex As Exception
     TextBox2.Text = ex.ToString
 End Try


You will still have to obtain their email from a textbox or however you choose to do that. Once you obtain their email and store it in a variable just replace "personsEmail@emailProvider.com" with that variable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900