Hi Egeberg,
If you want to avoid reinventing the wheel there is already a really slick freeware add-on to the Mail application that will do what you describe and quite a bit more. I use it all the time. If you're interested, its name is "
Mail.appetizer" and it's well worth having a look at.
I also understand that it can be fun to create your own "toys" that do what you want them to do
😉
To display a dialog and allow your script to proceed with what it's doing you need to "offload" your
display dialog statement to another application. The best way to accomplish this is to create an empty, "stay open" application that can work as a "slave" app for you that you can call on when you need it. If you save your script as a "
script bundle" you can store this empty application within your script and call on it using
path to resource NameOfYourHelperApp.
I can post an example of how this would work if you'd like. Like I mentioned before though, you
really need to be quite capable in scripting in order to properly write and debug a script like this. I really don't know what your skill level is and, because of this, hesitate to post an example due to the amount of description I would find necessary to teach someone all the steps necessary. Just let me know if you feel confident enough in your skills and I can definitely try posting an example script. I have a script that will, as far as I can tell by your description thus far, do exactly what you are asking. Also, if you could post the script you are currently using, I could incorporate it into the example for you.
I reiterate my thoughts on using "Mail.appetizer" though. I should note that I have absolutely no affiliation with the creators of this application. I just love it and use it ALL the time.