send mail w/Outlook


How do I send a mail with Outlook?

I knwo how to send mail with the default e-mail client.... but how do I send mail with Outlook if IT'S NOT THE DEFAULT MAIL CLIENT... (my default client is, in this case, Outlook Express, which I don't want to use)

I don't wnat to use 3rd party controls!

Thanks a lot for your help.
Who is Participating?
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.

There are two functions here, one is to create and launch the Outlook Application and the other is to create a new mailitem and send it.

However, in your project reference you must include the MS outlook library

Dim goOut As Object
Dim goOutRunning As Boolean

Function MSOutMail() As Integer
    Screen.MousePointer = ccHourglass
    On Error Resume Next
    Set goOut = Nothing        'Check to see if word is running
    Set goOut = GetObject(, "Outlook.Application")

    If goOut Is Nothing Then
        Set goOut = CreateObject("Outlook.Application")
        goOut.Visible = True
        goOutRunning = True
    End If
    If goOut Is Nothing Then
        MsgBox "Can't create Outlook Object"
        MSOutMail = False
        MSOutMail = True
    End If
    Screen.MousePointer = ccDefault
End Function

Function message23(Recv As String) As Integer
On Error GoTo Next23
Dim ol As Object
Dim AuthMsg As Object
Dim cSubject As String
Dim cBody As String
If MSOutMail = False Then GoTo Next23

Set ol = goOut
Set AuthMsg = ol.CreateItem(olMailItem)
AuthMsg.Recipients.Add Recv
cSubject = "Trial Mail"
cBody = "Body of Trial Mail

AuthMsg.Subject = cSubject
AuthMsg.Body = cBody
AuthMsg.ReadReceiptRequested = True

message23 = recOK
Set AuthMsg = Nothing
Set ol = Nothing
Set goOut = Nothing
GoTo message23Exit

Next23:    message23 = recNotFound
End Function

Hope this helps


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
trilloAuthor Commented:
Thanks a lot.
Do you know where I can find a reference to Outlook's objects?

If you have installed Outlook you would be able to locate it under the project reference else search for a file msoutl.tlb

Hope this helps

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

trilloAuthor Commented:
Hehe..... I didnt't mean That reference

I meant sometihng like a help file! (help reference)... Anyway it can't be very difficult to find out.

If you are interested to know what are the methods available, the way I do it is to check the functions available in the object browser from the VBA.  However, I guess if you look up in the books more help would be available

trilloAuthor Commented:
I think that might be the best solution

Thanks a lot!

Great to be helpful to you

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
Visual Basic Classic

From novice to tech pro — start learning today.