Suppose a certain letter from a certain sender comes to outlook. The content of this letter must be transferred to some program, and that, in turn, on the basis of the letter, will perform some actions, and then send a letter to this sender. Tell me how to achieve this behavior? Ps the work of the program it should not interfere.

    2 answers 2

    You have two options:

    1. Add-in for Outlook

    Creation documentation is here . In theory, if everything is done correctly, it should not interfere with the user. Disadvantages: the client is obliged to use Outlook, it is very likely (did not check) that the add-ins are tied to the Outlook version, for another client it will have to be wise; emails will be processed only when Outlook is launched, after updating the list of received emails.

    2. Through the mail server

    You can embed your email client into the program.

    • Mail on Exchange and a user in the domain: you can make authorization transparent for the user, without entering your login and password, but the user will be obliged to use this mail to work with this recipient.

    • Arbitrary mail server: requires separate authorization on behalf of the user in your program.

    • You can set up a separate mailing address for your program and set up forwarding the necessary letters to it. This will allow you to use any mail server and will relieve the user from having to log in, but the program will not respond on behalf of the user, but on its own behalf. Here you can make a substitution of the sender's address or use another hack, but this should be done carefully and correctly so as not to get into the spam lists.

    In any case, you will have to independently search for the necessary letters and keep track of those to which the answer has already been sent by your program.

    3. Mini server

    In this embodiment, the most problems, but in extreme cases, you can try.

    You can make from your program a sort of SMTP server to which to send the necessary letters to the only address, process as they arrive and send where it is needed, while if your users live on external mail (mail, yandex, google, etc.) , your program should be accessible from the global network, but it can be in a single copy for all your users.

    Either use SMTP relay technology and wrap the entire stream of sent mail to your program from which to filter the necessary - process and send further, unnecessary - immediately send further, but this will work only with the internal mail server, to the settings of which you have access, and also is likely to lead to spam lists, well, spam filters do not like forwarding servers, especially open, historically.

    • For option 2.3: if everything is done correctly, there will be no hit in the spam lists. "Correct" means that the program should send answers not directly - but through the same SMTP relay through which the user sends their letters. - Pavel Mayorov
    • @PavelMayorov I meant getting into spam when changing the sender's address, I got it on the default settings that wraps, regardless of the sender's server, why I didn’t understand, there was no need. But as a whole it is possible to get out of it - rdorn
    • Never written comments from a githaba? They are there, by the way, go with the substitution of the address. - Pavel Mayorov

    Obviously, you need to establish a connection with the mail server separately from the outlook (it has nothing to do with it), pass authorization, parse messages from the right senders and work with them. I advise you to google EWS Managed API 2.0