<CLSCompliant(True)> Private Sub cmdSend_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdSend.Click
Try
'Send the e-mail.
Dim FromEmailAddress As New MailAddress("" & txtEmailAddress.Text.Trim.ToString & "", "" & ProductName & " User")
Dim sMessageSubject As String = "[" & cboSeverity.Text.Trim & " Severity] " & ProductName & " User Message."
Dim sMessage As String = txtMessage.Text.Trim
Dim sMessageBody As String
Dim sColorCodeSeverity As String = Nothing
Select Case cboSeverity.SelectedItem.ToString
Case Is = "Low" '#00CC00 (Green)
sColorCodeSeverity = "<font color=#00CC00>Low</font>"
Case Is = "Medium" '#0099CC (Blue)
sColorCodeSeverity = "<font color=#0099CC>Medium</font>"
Case Is = "High" '#FF3300 (Red)
sColorCodeSeverity = "<b><font color=#FF3300>High</font></b>"
Case Is = "Urgent" '#FF6699 (Pink)
sColorCodeSeverity = "<b><font color=#FF6699>Urgent</font></b>"
Case Is = "Critical" '#993366 (Purple)
sColorCodeSeverity = "<b><font color=#993366>Critical</font></b>"
End Select
sMessageBody = "<font color=red><b>REMINDER:</b> If the end user has requested a reply e-mail, they were promised an e-mail within 48 hours.</font><br><br>" & _
"<table border=0 bordercolor=#FFFFFF style=background-color:#FFFFFF width=100% cellpadding=3 cellspacing=3>" & _
"<tr>" & _
"<td width=15%>Client Name:</td><td>" & txtName.Text.Trim & "</td></tr><tr>" & _
"<td width=15%>Contact Reason:</td><td>" & cboContactReason.SelectedItem.ToString & "</td>" & _
"</tr><tr>" & _
"<td width=15%>Requires a reply:</td><td>" & cboReplyBack.SelectedItem.ToString & "</td></tr><tr>" & _
"<td width=15%>Severity:</td><td>" & sColorCodeSeverity & "</td></tr></table><br>" & _
"<b>E-MAIL MESSAGE:</b>" & _
"<table border=0 bordercolor=#FFFFFF style=background-color:#FFFFFF width=100% cellpadding=3 cellspacing=3>" & _
"<tr><td>" & sMessage & "</td></tr></table><br>" & _
"<b>MACHINE INFORMATION:</b>" & _
"<table border=0 bordercolor=#FFFFFF style=background-color:#FFFFFF width=42% cellpadding=3 cellspacing=3>" & _
"<tr>" & _
"<td>Computer Name:</td><td>" & My.Computer.Name & "</td>" & _
"</tr><tr>" & _
"<td>Available Physical Memory:</td><td>" & My.Computer.Info.AvailablePhysicalMemory & "</td>" & _
"<tr>" & _
"<td>Available Virtual Memory:</td><td>" & My.Computer.Info.AvailableVirtualMemory & "</td>" & _
"</tr><tr>" & _
"<td>Total Physical Memory:</td><td>" & My.Computer.Info.TotalPhysicalMemory & "</td>" & _
"</tr><tr>" & _
"<td>Total Virtual Memory:</td><td>" & My.Computer.Info.TotalVirtualMemory & "</td>" & _
"</tr><tr>" & _
"<td>Operating System Full Name:</td><td>" & My.Computer.Info.OSFullName & "</td>" & _
"</tr><tr>" & _
"<td>Operating System Platform:</td><td>" & My.Computer.Info.OSPlatform & "</td>" & _
"</tr><tr>" & _
"<td>Operating System Version:</td><td>" & My.Computer.Info.OSVersion & "</td>" & _
"</tr>" & _
"</table><br>" & _
"<b>APPLICATION INFORMATION:</b>" & "<br>" & _
"<table border=0 bordercolor=#FFFFFF style=background-color:#FFFFFF width=100% cellpadding=3 cellspacing=3>" & _
"<tr>" & _
"<td>Application Name:</td><td>" & My.Application.Info.ProductName & "</td>" & _
"</tr><tr>" & _
"<td>Common Application Data Path:</td><td>" & CommonAppDataPath & "</td>" & _
"</tr><tr>" & _
"<td>Executable Path:</td><td>" & ExecutablePath & "</td>" & _
"</tr><tr>" & _
"<td>Local User Application Data Path:</td><td>" & LocalUserAppDataPath & "</td>" & _
"</tr><tr>" & _
"<td>Startup Path:</td><td>" & StartupPath & "</td>" & _
"</tr><tr>" & _
"<td>User Application Data Path:</td><td>" & UserAppDataPath & "</td></tr></table>"
Dim MailPriority As New Net.Mail.MailPriority
Select Case cboPriority.Text
Case "Low"
MailPriority = Net.Mail.MailPriority.Low
Case "Normal"
MailPriority = Net.Mail.MailPriority.Normal
Case "High"
MailPriority = Net.Mail.MailPriority.High
End Select
clsSendMail.SendMail(sMessageBody, _
sMessageSubject, _
Net.Mail.DeliveryNotificationOptions.OnFailure, _
MailPriority, _
ToEmailAddress, _
FromEmailAddress, _
Nothing, _
Nothing, _
Nothing)
Catch ex As InvalidCastException
MessageBox.Show(ex.Message, _
"Invalid Cast Exception.", _
MessageBoxButtons.OK, _
MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.DefaultDesktopOnly, _
False)
Catch ex As FormatException
MessageBox.Show(ex.Message, _
"Format Exception.", _
MessageBoxButtons.OK, _
MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.DefaultDesktopOnly, _
False)
Finally
If cboReplyBack.Text = "Yes" Then
MessageBox.Show("Your e-mail message was successfully sent, " & txtName.Text.Trim & "!" & vbNewLine & _
"You will hear from us via e-mail within 48 hours.", _
"E-mail Successfully Sent.", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.DefaultDesktopOnly, _
False)
Else 'No.
MessageBox.Show("Your e-mail message was successfully sent, " & txtName.Text.Trim & "!", _
"E-mail Successfully Sent.", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.DefaultDesktopOnly, _
False)
End If
End Try
End Sub