Private Sub sendemail()
Dim CustomerEmail As String
CustomerEmail = txtCustomerEmail.Text
'Checks if Email is in DB
Dim da As New ProjectDataSetTableAdapters.LicenseTableAdapter()
Dim dt As ProjectDataSet.LicenseDataTable = da.GetDataByCustomerEmail(CustomerEmail)
If dt.Rows.Count = 0 Then
txtCustomerEmail.Text = "Email Address Not Found"
Else
'Check if the order has been paid
'*********************************
'*********************************
'if so then email activaion details
Dim daLic As New ProjectDataSetTableAdapters.LicenseTableAdapter()
Dim dtLic As ProjectDataSet.LicenseDataTable = daLic.GetDataByCustomerEmail(CustomerEmail)
If dtLic.Rows.Count > 0 Then
Dim drLic As ProjectDataSet.LicenseRow = dtLic.Rows(0)
Dim msg As New MailMessage()
msg.IsBodyHtml = False
msg.To.Add(CustomerEmail)
msg.Subject = "MyWebsite Activation ID"
Dim body As New StringBuilder()
body.AppendLine("Thank you for your purchase")
body.AppendLine()
body.AppendLine("Here are your activation details:")
body.AppendLine()
For i As Integer = 0 To dtLic.Count - 1
drLic = dtLic.Rows(i)
body.AppendLine(String.Format("{0} Activation Code: {1} | Email: {2}", drLic.Product, drLic.ActivationCode, drLic.CustomerEmail))
body.AppendLine(String.Format("{0} Download Link: www.MyWebsite.co.uk/{0}setup.html", drLic.Product, drLic.ActivationCode))
body.AppendLine()
Next
body.AppendLine()
body.AppendLine("Please note each license code above is for 1 PC only")
body.AppendLine()
body.AppendLine()
body.AppendLine("Thank You")
body.AppendLine()
body.AppendLine("MyWebsite")
body.AppendLine("www.MyWebsite.co.uk")
body.AppendLine()
msg.Body = body.ToString()
Dim smtp As New SmtpClient()
smtp.Send(msg)
End If
End If
End Sub