I create Outlook mail in Excel VBA, but the mail screen may not be active after execution, so please tell me how to activate it (frontline).

Asked 2 years ago, Updated 2 years ago, 86 views

When I create Outlook mail in Excel VBA, the mail screen may not be active after execution. How do I activate it?

The code looks like the following

DimobjOutlookAsOutlook.Application
 DimobjMailAsOutlook.MailItem
 SetobjOutlook=CreateObject("Outlook.Application")
 SetobjMail=objOutlook.CreateItem(olMailItem)
 With objMail
 .To="[email protected]" 
 .Subject="Regarding 〇 の 〇" 
 .BodyFormat=olFormatPlain 
 .Body="Email Body" 
 .Display
 End With

vba excel mail

2022-09-30 19:51

2 Answers

I got here because I wanted to do the same thing.

.Display
and
End With

during .GetInspector.Activate
If you put in one line, it's done.


2022-09-30 19:51

I also found that the above corrections do not come forward.

Therefore, I am trying to rewrite it as follows.

before modification:

.GetInspector.Activate

modified:

.GetInspector.Display(False)


2022-09-30 19:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.