In the code below, I'm trying (works) to insert a mail message
before the signature line. With each new email within a run, 
the email new window flashes on the user's desktop. I'd like to
minimize to outlook window to reduce the 'flashing'. The email is
sent correctly but I need to minimize.

Thank you.


Private Function setEmailSend(ByVal sSubject As String, ByVal sBody As String, _
                    ByVal sTo As String) As Boolean

    Dim ins As Outlook.Inspector

    setEmailSend = False
    oApp = New Outlook.Application
    oMsg = CType(oApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook._MailItem)
    oMsg.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
    '---------------------------
    'This code does not work
    '---------------------------
    If firstsw = 0 Then
        ins = oMsg.GetInspector
        ins.Activate()
        ins.WindowState = Outlook.OlWindowState.olMinimized
        firstsw = 1
    End If
    '---------------------------
    oMsg.Display()
    oMsg.Subject = sSubject
    oMsg.HTMLBody = oMsg.HTMLBody.Insert(0, "<font face=""Courier New"">" & sBody & "</font>" & br & br & br)
    oMsg.To = sTo
    Try
        oMsg.Send()
    Catch
        errmes = "Outlook probably is not running..." & vbCrLf &
               "Start Outlook then rerun this program"
        Me.Show()
        Me.TopMost = True
        MsgBox(errmes, vbCritical)
        Me.Dispose()
        End
    End Try

    setEmailSend = True

End Function

It seems as though I must use oMsg.display to refresh the signature line. I guess what I'd like to to is display it minimized. Any help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.