Hi, Good Evening to everyone!
I am preparing one application facing some challenges, the scenrio is to send email when a user enter a complaint in the system to the assigned user the assigned user have email address already in the system the email notification should go to assigned user alongwith Complaint ID and complaint detail. then if after 30 minutes no one updates the status the system should send another notification to next level after 1 hour if still status not updated the system should send email notification to final level. could you please help me with code sample if possible. i am able to send notification using below code but unable to figure out how to send complaint details.

Sub email_send() On Error Resume Next Dim mail As New MailMessage() Dim SmtpServer As New SmtpClient SmtpServer.Credentials = New Net.NetworkCredential("abc@gmail.com", "mypassword") SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" SmtpServer.EnableSsl = True SmtpServer.EnableSsl = True mail.To.Add("abc@gmail.com") mail.From = New MailAddress("abc@gmail.com") mail.Subject = "Subject" mail.Body = "Body" SmtpServer.Send(mail) End Sub Thanks in Advance for youe great help always

Here's your code formatted:

Sub email_send() 
    On Error Resume Next 
    Dim mail As New MailMessage() 
    Dim SmtpServer As New SmtpClient 
    SmtpServer.Credentials = New Net.NetworkCredential("abc@gmail.com", "mypassword") 
    SmtpServer.Port = 587 
    SmtpServer.Host = "smtp.gmail.com" 
    SmtpServer.EnableSsl = True
    mail.To.Add("abc@gmail.com") 
    mail.From = New MailAddress("abc@gmail.com") 
    mail.Subject = "Subject" 
    mail.Body = "Body" 
    SmtpServer.Send(mail) 
End Sub

To answer your question replace the string "Body" with the complaint details. If you don't know how to get those, that's a totally different question

 con.ConnectionString = ConnectionString
        Try
            dsOle.Clear()
            dtOle.Clear()
            cmdOle = con.CreateCommand
            da.SelectCommand = cmdOle
            Dim eaddress As String
            cmdOle = New OracleCommand("SELECT EMAIL_ADDRESS FROM USERS WHERE USERNAME = '" & ComboBox2.Text & "'", con)
            da.SelectCommand = cmdOle
            da.Fill(dsOle, "USERS")
            eaddress = (dsOle.Tables(0).Rows(0).Item(0))
            Dim mail As New MailMessage()
            Dim SmtpServer As New SmtpClient("smtp.office365.com")
            mail.From = New MailAddress("XXX.XXXX@gmail.COM")
            mail.[To].Add(eaddress)
            mail.Subject = "Complaint Details"

            Dim qry As String
            Dim dsbody As New DataSet
            qry = "select comp_type,LOCATION,COMPLAINT_DETAIL,REMARKS from complaint"
            cmdOle1 = New OracleCommand(qry, con)
            dsbody.Clear()
            da1 = New OracleDataAdapter(cmdOle1)
            da1.Fill(dsbody, "Complaint")
            Dim dts As New DataTable
            Dim dv As New DataView(dsbody.Tables(0))
            dts = dv.ToTable()

            mail.Body = " <html><head><title>Complaint details</title></head><table border=1><tr bgcolor=#6699FF ><th <th bgcolor=#6699FF>Complaint Location><th bgcolor=#6699FF>Complaint Type<th bgcolor=#6699FF><th bgcolor=#6699FF>Complaint Remarks</th></tr></html>"
            mail.IsBodyHtml = True
            SmtpServer.Port = 587
            SmtpServer.Credentials = New Net.NetworkCredential("xxx@dmail.com", "PWD")
            SmtpServer.EnableSsl = True
            SmtpServer.Send(mail)
            MessageBox.Show("The Complaint Sent to Respective department")
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            con.Close()
        End Try

I figure out a way how to select specific email for the assigned complaint handler and able to send email also but data is not coming only headings actually i need to send the currently inserted record as notification to the user.

Could you please help me out to adjust this code.

Thanks in advance.

It looks to me you need to create an html table from a DataTable. Here's a blog post that should help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.