Results 1 to 2 of 2
  1. #1
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58

    Can't Open Outlook From Access With Simplest Code

    I'm going to scream so loud my desktop monitor screen won't survive...



    I cannot get these simplest of test codes to execute. I'm just trying to open Outlook using vb code behind a button on an Access form.

    1) Dim olApp As Outlook.Application
    Set olApp = New Outlook.Application

    OR

    2) Dim olApp As Outlook.Application
    Set olApp = CreateObject("Outlook.Application")

    I added both the "Microsoft Access 12.0 Object Library" and "Microsoft Outlook 12.0 Object Library" to my References.

    All relevant Visible properties are set to "yes".

    Both code versions run without errors (my F8/Step Into debugging feature not working is another issue; I have the Special Keys in Options checked. )....but Outlook doesn't open.

    Nothing is working. How could a two line block of code not work. Only Microsoft could make that a reality.

    Please rescue me from this limbo before I'm awarded a digital limbotamy.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I expect that Outlook is open, just not visible. Set a breakpoint after the Set line, run procedure, when it stops on the breakpoint, check Windows Task Manager to see if Outlook is listed under Processes but not Applications. This works for me:
    Code:
    Public Sub TestEmail()
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
        .BodyFormat = olFormatRichText
        .To = "email address"
        ''.cc = ""
        ''.bcc = ""
        .Subject = "HTML TEST"
        .HTMLBody = "<HTML><body>" & _
                    "<font color='red'>This is a test</font>" & _
                    "<body><HTML>" & _
                    Chr(10) & Chr(13) & Now
        ''.Attachments.Add (strZip)
        .DeleteAfterSubmit = True 'to not save in sent bin
        .Display
        .Send
    End With
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. FORMATTING Outlook Email in BODY of Access code
    By taimysho0 in forum Programming
    Replies: 7
    Last Post: 11-28-2011, 11:04 AM
  2. Replies: 3
    Last Post: 09-14-2011, 05:27 PM
  3. Open Outlook window but don't send
    By Paul Taylor in forum Access
    Replies: 2
    Last Post: 04-07-2011, 11:51 AM
  4. Open Outlook & populate e-mail
    By NISMOJim in forum Forms
    Replies: 7
    Last Post: 10-09-2010, 01:01 PM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums