Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating an advanced error handler in VB6

Creating an advanced error handler in VB6

Creating an advanced error handler in VB6

can anyone help me with a problem that I'm having: how do i create an advanced error handler which will take the error that comes up, copy and paste it to an outlook new message, using the mailto: command.
Many thanks in advance!!

RE: Creating an advanced error handler in VB6

Well I have 90% of it here:
But it prompts for you to hit send.
Insert this Declare in your module

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

' Raise the exception
s = 3 / 0

Exit_Command1_Click: '<<< Put all this code at the bottom right above the END SUB
Exit Sub

Select Case Err.Number
Case 3021
' No current record

Case Else
MsgBox "Error # " & Err.Number & " " & Err.Description, vbInformation, "In sub Command1_Click"

End Select

Dim stext As String
Dim sAddedtext As String

stext = "mailto:" & "douglasp"

sAddedtext = sAddedtext & "&Subject=" & "Error From VB Program " & Err.Number & " " & Err.Description
sAddedtext = sAddedtext & "&Body=" & "Put your Body Text here if needed"

'Add an attachment if needed
'If Len(txtAttachment) Then
'sAddedtext = sAddedtext & "Attach=" & Chr$(34) & Me!txtAttachment & Chr$(34)
'End If

stext = stext & sAddedtext

' launch default e-mail program
If Len(stext) Then
Call ShellExecute(Me.hwnd, "open", stext, vbNullString, vbNullString, SW_SHOWNORMAL)
End If

Resume Exit_Command1_Click

End Sub


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close