PARTHIBAN KANNAN

Think Special… Do Special…

Get Software Bugs via Outlook Mail

Send Bugs Via Mail

[sgrb_review id=2]

Some Bugs are an inevitable at the client side due to the environment changes in clients place such as System Configuration, Server configuration, Database configuration, & much more stuff.

Sometimes, we cannot get the proper technical information from the client side about the bug. We have to find out the function where the bugs occur. To resolve these issues, we need to implement proper bugs handling method with our coding.

In this method, You will learn to

  • Capture the bug details
  • Use Outlook Interop Service
  • Get the error function name at runtime

Here, Vb.Net Project & Outlook Interop Service – Used

 

STEPS TO IMPLEMENT THIS SYSTEM

  1. Create a Module name “mdlErrorHandling.vb” in  in your VB.Net Project
  2. Create a shared Function named “func_sendToDeveloper” inside the mdl_ErrorHandling class
  3. Call the function func_sendToDeveloper wherever need to capture exception

[Simply Copy & Paste the below Code to your file]

    Public Shared Function func_sendToDeveloper(Exception As String)

        Try

‘SET THE NAME OF THE FILE HANDLING BY THE APPLICATION  – FILE NAME VERY MUCH USABLE IN BUG TEST

            Dim FileName = “DOCUMENT-1”   

‘SET THE APPLICATION NAME – TO HANDLE APPLICATION WITH THE CLIENT

            Dim ApplicationName = “APPLICATION-1” 

‘SET THE SUBJECT TO DISPLAY IN MAIL VIEW

            Dim Subject As String = “NEW BUG : “ & ApplicationName & ” – “ & FileName    

            Dim Body As String = Exception

‘SET THE DEVELOPER MAIL TO GET THE BUG DETAILS

            Dim ToMail As String = “cse@jkparthiban.com”   

‘SET THE CC OPTION TO ADD MANAGER OR SOME OTHERS MAIL ID FOR BUG REVIEW (OPTIONAL)

            Dim CCMail As String = “manager@jkparthiban.com

‘SET THE FILE NAME IF YOU WOULD LIKE ADD ATTACHMENT WITH THE MAIL

            Dim AttachmentName As String = “”   

            Dim DisplayName As String = “BUG at “ & ApplicationName

‘CALL THE OUTLOOK INTEROP SERVICE

            Dim OutlookApp As Interop.Outlook._Application

            OutlookApp = New Interop.Outlook.Application   

‘CREATE A NEW E-MAIL ITEM

            Dim OutlookMessage As Interop.Outlook._MailItem

            OutlookMessage = OutlookApp.CreateItem(Interop.Outlook.OlItemType.olMailItem)  

‘ SET SUBJECT OF THE E-MAIL

            OutlookMessage.Subject = Subject 

  ‘ SET THE BODY CONTENT AS EXCEPTION DETAILS

            OutlookMessage.Body = Body    

‘SET THE TO MAIL TO DEVELOPER         

  OutlookMessage.To = ToMail

 ‘SET THE CARBON COPY TO MANAGER (OPTIONAL)    

            OutlookMessage.CC = CCMail         

‘ADD ATTACHMENT WITH YOUR MAIL

            If AttachmentName <> “Directory:\File.ext” Then   

                Dim BodyLen As Integer = Int(Body.Length)

                Dim OutlookAttachments As Interop.Outlook.Attachments = OutlookMessage.Attachments

                Dim OutlookAttachment As Interop.Outlook.Attachment = OutlookAttachments.Add(AttachmentName, BodyLen, DisplayName)

            End If

‘SEND THE MAIL

            OutlookMessage.Send()        

        Catch ex As Exception                   ‘ GET THE EXCEPTION ANYTHING OCCURS

‘GET THE CURRENT FUNCTION NAME TO CAPTURE THE METHOD WHERE EXCEPTION OCCURS

            Dim FunctionName As String = Reflection.MethodBase.GetCurrentMethod.ToString    

   ‘SEND THE EXCEPTION DETAILS TO THE DEVELOPER, IF EXCEPTION OCCURS IN THIS FUNCTION

            func_sendToDeveloper(ex.ToString)                                      

        End Try

    End Function

 


[Call this code wherever exception need to capture]

Now call the below codes in your project wherever catching exception

‘GET THE CURRENT FUNCTION NAME TO CAPTURE THE METHOD WHERE EXCEPTION OCCURS

            Dim FunctionName As String = Reflection.MethodBase.GetCurrentMethod.ToString    

   ‘SEND THE EXCEPTION DETAILS TO THE DEVELOPER

            func_sendToDeveloper(ex.ToString)                                         

 Note: You have to implement try…catch to capture the exception


Now you are ready to get the bugs via mail.