Convert visual basic to C#.net

  • Thread starter Thread starter Ravi Kumar12233
  • Start date Start date
R

Ravi Kumar12233

Guest
Hello all , Sorry i know this is too much to ask , but i am helpless as i am very new to c# .net .

I was using this below code to automatically send mail to the concerned if the task is over due in access database , the overdue criteria was fulfilled by a query.

but now i am creating a winform app for the same database :"CSC.accdb", "Tasks_Bindingsource", "Tasks_tableadapter" , "Tasks_table".

Now i want to convert this below code from VBA to C# and use it in a button click event , which i searched for hours in internet but couldn't find anything & also i don't know how can i pass the criteria (which is less today of the "scheduled" column) ,So by looking at the code below kindly help how to achieve the same in winforms app.

Option Compare Database



Private Sub cmdtrial_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim emailto As String
Dim emailcc As String
Dim emailsubject As String
Dim emailtext As String
Dim outapp As Outlook.Application
Dim outmail As Outlook.MailItem
Dim outstarted As Boolean
Dim rpt As Report
Dim pdfmail As String

On Error Resume Next
Set outapp = GetObject(, "outlook.application")
On Error GoTo 0
If outapp Is Nothing Then
Set outapp = CreateObject("outlook.application")
outstarted = True
End If

Set db = CurrentDb
Set rs = db.OpenRecordset("qryeMailOverdueTasks")
DoCmd.OutputTo acOutputReport, "tasks", acFormatPDF, "tasks.pdf"
Do Until rs.EOF
emailto = rs.Fields("responsible person").Value
emailcc = "Abishek.Gowda@plansee.com"
emailsubject = "Pending tasks to complete the issue regarding" & " " & rs.Fields("issue").Value
emailtext = "Hello" & vbCrLf & "Kindly complete the task which is in the attached file to complete the cutomer isue regarding" & " " & rs.Fields("issue").Value
pdfmail = "tasks.pdf"
Set outmail = outapp.CreateItem(olMailItem)
outmail.To = emailto
outmail.CC = emailcc
outmail.Subject = emailsubject
outmail.Body = emailtext
outmail.Attachments.Add ("tasks.pdf")
outmail.Send

rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing

If outstarted Then
outapp.Quit
End If

Set outmail = Nothing
Set outapp = Nothing

End Sub

Continue reading...
 
Back
Top