Email Notification

5 pts.
Tags:
SQL Server database
VB.NET
Hey I'm creating an application front end = vb.net and back end = SQL Server DB!! The application helps assign staff to jobs and when an assignment occurs I would like the staff to receive an email informing them that they have been assigned to a job. Can anyone help me out with how I would go about doing this?

Software/Hardware used:
vb.net and sql server

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is the function I wrote and use in my code. You will need to Import System.Net and System.Net.Mail at the top of the page you put it in. Below the code is the link to the reference pages for these two classes.

Private Function SendMail(Server As String, User As String, Password As String, Sender As String, Recipient As String, Subject As String, Body As String) AS Boolean
Dim client As SmtpClient
Dim email As MailMessage

email = New MailMessage(Sender, Recipient, Subject, Body)
client = New SmtpClient(Server)
client.UseDefaultCredentials = False
client.Credentials = new NetworkCredential(User, Password)
Try
client.Send(email)
Catch ex As System.Exception
'You'll need some code here to get an error message back to you.
Return False
End Try
Return True
End Function

Look at this one to figure out how to add CC and such.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Gent01
    BTW, you will need an email account like the one your ISP gave you. The server will be their mail server, usually mail.yourispsdomain.com, and the user name/password for the account. Or if you have your own mail server you can use it. If it doesn't require you to authenticate, delete the two lines with credential in them and remove the server, user, and password parameters of the function.
    1,870 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following