Al C
Al C

Reputation: 5377

How do you restore size and focus to your form after another application's form closes?

I have a procedure that ultimately formats an email message and sends the info to the user's default email client. I minimize my application just before this happens.

After the user clicks the 'send' button on his or her email client, I'd like my application to restore itself--but not before. A simple Application.Restore doesn't do it because my app will be restored before the user has clicked his or her email 'send' button (closing the mail app's form). In other words, Application.Restore restores the main form on top of the email client, before the user has sent an email message.

Upvotes: 0

Views: 342

Answers (1)

SourceMaid
SourceMaid

Reputation: 473

For this to work you need to at least know which window to monitor. Increasing numbers of people now use webmail rather than an email opplication, to the point where invoking the computer's email application by default causes more confusion than it's worth. And then there's the plethora of possible email clients, not to mention the possibility that the user may already be composing an email message when your function runs.

I suggest you consider one of the following alternatives.

  1. If the application is targeted at the technically competent, have them enter their own SMTP server details and use that to send your email message.
  2. Write an interface in something like PHP that'll turn the request string into an email message and send it on its way from the server of your choice. You can then provide a form within your application for message composition and use an HTTP component to send the request to the URL hosting the interface. There's a simple example in this article.
  3. The simplest option is not to minimse your application, and give the user the choice of having the computer's default email application opened, or the email address copied to the clipboard for pasting into a webmail message.

With both [1] and [2] you'll know when the message has been sent, and also whether sending was successful. With [3] it won't matter.

Upvotes: 1

Related Questions