troubleshooting Question

Why is email being sent even though I have .Display turned on

Avatar of SteveL13
SteveL13Flag for United States of America asked on
Microsoft Access
4 Comments1 Solution79 ViewsLast Modified:
I have the following code in place for an onclick event of a command button.  The mail event is working fine EXCEPT it is not allowing me to preview the email before it gets sent.  Can someone figure out why?

    Dim oOutlook As Object
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Dim strPath As String
    Dim strFilter As String
    Dim strFile As String
    Dim strAttachmentFolderDataPath As String

    On Error Resume Next
    Set oOutlook = GetObject(, "Outlook.Application")
    On Error GoTo 0

    If oOutlook Is Nothing Then
        MsgBox "Outlook is not open, open Outlook and try again"
    Else

    'Email routine...
    strPath = DLookup("AttachmentDirectory", "LOCALtblDatabaseSetup") & "\" & Me.txtContractN

    strFilter = "*.pdf"
    strFile = Dir(strPath & strFilter)

        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)

        With MailOutLook
            .BodyFormat = olFormatRichText
            .To = "somebody@somewhere.com"
            ''.cc = ""
            ''.bcc = ""
            .Subject = "Report Attached"
            .HTMLBody = "Report Attached"
            .Attachments.Add strPath & "\Report.PDF"
            .Display
            .Send
        End With
    'End of email routine

    End If
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros