Bobbit31 here are your points.

Sorry about that.  Maybe you can help me with this, I have added some addtional points so you aren't getting the shaft.  I have the following script to send emails however everytime I try to use it I get an error that says "User-Defined type not defined" can you help me?

------------------------------  Script  -------------------------------
Public Function fhpSendEmail(strRecip As String, strSubject As String, strMsg As String, Optional strCC As String) As Boolean
' ----------------------------------------------------- '
' Purpose      : Send an e-mail to an Outlook recipient '
' ----------------------------------------------------- '
On Error GoTo Error_fhpSendEmail
  Dim strInfoMsg As String                                      'Info message
  Dim objOutlook As Outlook.Application                         'Outlook variable
  Dim objOutlookMsg As Outlook.MailItem                         'Outlook variable
  Dim objOutlookRecip As Outlook.Recipient                      'Outlook variable
  If (strRecip <> "") And (strSubject <> "") And (strMsg <> "") Then
    Set objOutlook = CreateObject("Outlook.Application")        'Create the Outlook session
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)       'Create the message

    With objOutlookMsg                                          'The message
      Set objOutlookRecip = .Recipients.Add(strRecip)           'Recipient of the message
      objOutlookRecip.Type = olTo

      If strCC <> "" Then                                       'If CC recipients
        Set objOutlookRecip = .Recipients.Add(strCC)            'CC recipients
        objOutlookRecip.Type = olCC
      End If
      .Subject = strSubject                                     'Message subject
      .Body = strMsg & vbCrLf & vbCrLf                          'Message content
      .Importance = olImportanceNormal                          'Message importance

      For Each objOutlookRecip In .Recipients                   'Resolve each Recipient's name
      .Save                                                     'Save message
      .Send                                                     'Send message
    End With
    fhpSendEmail = True                                         'Message sent
  Else                                                          'If not enough information
    strInfoMsg = "Unable to send message because you have supplied to few data!" & vbCrLf & _
                 "Info needed are :" & vbCrLf & _
                 "Recipient" & vbTab & vbTab & "The person to recieve the mail" & vbCrLf & _
                 "Subject" & vbTab & vbTab & "What the mail is about" & vbCrLf & _
                 "Message " & vbTab & vbTab & "The text you want to send"
    MsgBox strInfoMsg, vbCritical + vbOKOnly, "Error sendig e-mail"
    fhpSendEmail = False                                        'Message NOT sent
  End If

  Set objOutlook = Nothing                                      'Release object
  Set objOutlookMsg = Nothing                                   'Release object
  Set objOutlookRecip = Nothing                                 'Release object
  Exit Function

  fhpSendEmail = False                                          'Message NOT sent
  Select Case Err
    Case Else
      MsgBox Err.Number & ": " & Err.Description, vbOKOnly + vbCritical, "Error in function 'fhpSendEmail'"
      Resume Exit_fhpSendEmail
  End Select

End Function
----------------------------------------  BREAK  ---------------------------------------------
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gideonnAuthor Commented:
Oh and it stops here

Dim objOutlook As Outlook.Application

it says that "ObjOutlook as Outlook.Applcation" is not defined however I have already referenced the Outlook 9 OCX.
where do you get the error? (what line?)
gideonnAuthor Commented:
Sorry it was an after thought.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

are you sure you referenced Microsoft Outlook Object under project references?

the above code works and compiles fine for me... and the reason it's giving you that error is b/c it doesn't know what Outlook.Application is.

Do the auto-sensing (auto-complete) work if you type Outlook. (dropdown should appear)
also, since you are using latebinding anyway... you could do this instead:

Dim objOutlook As Object                         'Outlook variable
Dim objOutlookMsg As Object                         'Outlook variable
Dim objOutlookRecip As Object                      'Outlook variable

your CreateObject calls will set the object to it's proper type (you won't get the auto-sensing though)
There are advantages and disadvantages b/w using early and late binding... do a search on it in the vb forum and you'll find out more.

one of the important ones is that when you use CreateObject("Outlook.Application") it will find ANY version of Outlook if it's installed.

when you reference Outlook Object 9.0 it's assuming that the client has Outlook 9.0 installed.

b/c the compiler doesn't know what objOutlook etc... is at compile time and how much memory it will need, it adds extra overhead to your app during runtime.


if you reference MS Outlook 9.0 object library and wish to use early binding:

Dim objOutlook As New Outlook.Application

late binding:

Dim objOutlook as Object
Set objOutlook = CreateObject("Outlook.Application")
gideonnAuthor Commented:
How about this, is there a "Mailto" equivlant in VB.  In other words is there a way to have a command to open a email and fill out the "Subject", "To", and "Main" boxes and allow the user to send it.  That way the user can make changes to the email as needed?  Thanks.
you mean just to launch the default mail client like in html?


hold on let me look ;)
gideonnAuthor Commented:
Basically but for instance the previous script that I put up is a function and the tool tip for filling it out shows that you can input information in the various fields on the email itself.  (I.E. Subject, To, etc...)  I need something that will allow me to do that but will not automatically send the email and will not require a lot of over head.  I want it to just pull up the blank email fill in what it knows and then the user can do whatever they want.  Does that make sense?  Thanks!
yeah... hold on
Private 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 Const SW_SHOWNORMAL = 1

Private Sub Command1_Click()
Dim strTo As String
Dim strSub As String
Dim strMsg As String
Dim sFinal As String

strTo = ""
strSub = "Subject (test)"
strMsg = "Message (test)"

sFinal = strTo & "?subject=" & strSub & "&body=" & strMsg

ShellExecute Me.hwnd, "open", "mailto:" & sFinal, vbNullString, vbNullString, SW_SHOWNORMAL

End Sub
gideonnAuthor Commented:
Method  or data member not found on

ok, do this:

ShellExecute 0, "open", "mailto:" & sFinal, vbNullString, vbNullString, SW_SHOWNORMAL

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gideonnAuthor Commented:
Thank you so much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.