We help IT Professionals succeed at work.
Get Started

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

SteveL13
SteveL13 asked
on
76 Views
Last Modified: 2017-11-24
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

Open in new window

Comment
Watch Question
Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE