[AccessD] First run creating Outlook mail item does not foreground itself?

Ryan W wrwehler at gmail.com
Tue Jan 24 12:37:03 CST 2023


Bill,
 Thanks but neither of those worked.

 I did find instances where if outlook was displaying the email as one
would expect, next time around (with enough idle time for outlook or some
other event) it will cease to foreground the composition window
occasionally.



On Tue, Jan 24, 2023 at 12:19 PM Bill Benson <bensonforums at gmail.com> wrote:

> “,” was typo, meant “.”
>
> On Tue, Jan 24, 2023 at 1:18 PM Bill Benson <bensonforums at gmail.com>
> wrote:
>
> > Try adding oMail,GetInspector.Activate or oLook.ActiveInspector.Activate
> > after .Display
> >
> > On Tue, Jan 24, 2023 at 11:56 AM Ryan W <wrwehler at gmail.com> wrote:
> >
> >> As the subject states:
> >>
> >> When I run code to compose an email and display the email, the email
> >> window
> >> stays grouped but minimized or hidden on the first run.
> >>
> >> Subsequent runs, the created email is foregrounded?
> >>
> >> If I close outlook and re-open it, the process starts again where the
> >> first
> >> composition stays hidden until I go manually foreground it.
> >>
> >> code:
> >>
> >> Public Sub CreateEmail(subj As String, Optional body As String, Optional
> >> ToWho As Variant, Optional CCWho As Variant, Optional attachment As
> >> Variant
> >> = Null)
> >>     On Error GoTo CreateEmail_Error
> >>
> >>     Dim oLook As Object, oMail As Object, origBody As String
> >>
> >>     On Error Resume Next
> >>     Set oLook = GetObject(, "Outlook.Application")
> >>     If Err.number <> 0 Then
> >>         Set oLook = CreateObject("Outlook.Application")
> >>     End If
> >>     Err.Clear
> >>     On Error GoTo CreateEmail_Error
> >>     Set oMail = oLook.CreateItem(0)
> >>     With oMail
> >>         .Display
> >>         If Not (IsMissing(ToWho) Or IsNull(ToWho)) Then .To = ToWho
> >>         If Not (IsMissing(CCWho) Or IsNull(CCWho)) Then .cc = CCWho
> >>         .Subject = subj
> >>         .BodyFormat = 2 'html
> >>         .body = body
> >>         If Not IsNull(attachment) Then
> >>             .Attachments.Add attachment
> >>         End If
> >>     End With
> >>
> >> CreateEmail_Exit:
> >>     On Error Resume Next
> >>     Set oMail = Nothing
> >>     Set oLook = Nothing
> >>     Exit Sub
> >>
> >> CreateEmail_Error:
> >>
> >>     MsgBox "Error " & Err.number & " (" & Err.Description & ") in
> >> procedure
> >> CreateEmail."
> >>     Resume CreateEmail_Exit
> >> End Sub
> >>
> >>
> >> IIRC .Display should show the email composition window.
> >>
> >>
> >> Any ideas?
> >> --
> >> AccessD mailing list
> >> AccessD at databaseadvisors.com
> >> https://databaseadvisors.com/mailman/listinfo/accessd
> >> Website: http://www.databaseadvisors.com
> >>
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list