2

The team here runs jobs on their PC, then has it launch an email, make an attachment, then send it. They can schedule this job. The problem they have is it pops a window asking if you want to send the email being sent by another program, so it snags the idea of overnight jobs that send emails.

What's the prospect of writing a console listener that sits in the tray and watches for this specific window, then simulates the user clicking the send button to dismiss it and send the email?

Seth Moore
  • 3,575
  • 2
  • 23
  • 33
SuperTroye
  • 21
  • 3
  • 1
    How are they sending the email in .Net? I think you should try figuring out a way to not have the window pop up. I've seen numerous applications of the SmtpClient that do this. – Seth Moore Apr 20 '11 at 14:51
  • The application that needs to be monitored is not a .Net app, so using SmtpClient is not a solution. – SuperTroye Apr 20 '11 at 15:08
  • You can create email-sending app from C# in a matter of minutes - there are lots of examples on the net. What is the purpose of you using some specific app to send emails? (and to address your original question - yes, it's doable. There are some automated tests for GUI that are using exactly this functionality - when you record the test, it catches the occurrence of the window, memorizes what button you clicked etc... the VS has it, but I'm not sure if you can export that script and create a separate app from it. – veljkoz Apr 20 '11 at 15:08

2 Answers2

0

I would agree with some of the other comments - it would be better to "fix" the popup. This might be the cause:

http://office.microsoft.com/en-us/outlook-help/i-get-warnings-about-a-program-accessing-e-mail-address-information-or-sending-e-mail-on-my-behalf-HA001229943.aspx.

As for monitoring, it is possible in MFC - I am sure it can be done in C# too. The idea would be to monitor the top level window, if it is the specific title of your popup, then send a click message to the "OK" button on that window.

http://www.codeproject.com/Messages/3325483/sending-click-message-to-child-button-of-a-window.aspx

Blazes
  • 4,721
  • 2
  • 22
  • 29
0

You say they have to attach a file to the email? Perhaps they could just dump the file in a folder that you're monitoring with a .Net app and the .Net app takes care of sending the email.

This seems like it would be a much cleaner and more elegant way of doing things.

You could also try checking out this question.

Community
  • 1
  • 1
Seth Moore
  • 3,575
  • 2
  • 23
  • 33