send mail w/Outlook

Hi!

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.
LVL 2
trilloAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ivancConnect With a Mentor Commented:
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
    Else
        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.Display
AuthMsg.ReadReceiptRequested = True

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

Next23:    message23 = recNotFound
message23Exit:
End Function

Hope this helps

Ivanc
0
 
trilloAuthor Commented:
Thanks a lot.
Do you know where I can find a reference to Outlook's objects?
0
 
ivancCommented:
Trillo

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

Ivanc
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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.
Thanks
0
 
ivancCommented:
Trillo

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

Ivanc
0
 
trilloAuthor Commented:
I think that might be the best solution

Thanks a lot!
0
 
ivancCommented:
Trillo

Great to be helpful to you

Ivanc
0
All Courses

From novice to tech pro — start learning today.