After 15 years, I have finally reached the point where I use Outlook as my build pipeline
Posted by codingtofreedom@reddit | programming | View on Reddit | 43 comments
I had an annoying problem at work where we had to work around some less-than-optimal firewall rules, and because we are working on a tool that requires quite frequent testing (like several times per hour we work on it), it was really adding up to take these five-minutes per file that it took to get them from my coworker's machine to mine, and I quickly designed a server workflow that could take the encoded file and save it to its own file system.
Because we could not find a good way to bring these files over, we figured it was actually a good idea to send it via email to an inbox with a specific subject line, and then have a Python script on my end checking the inbox every minute to then take the attached file and send it to the endpoint.
This has to be one of the hackiest solutions I have come up with over the years for a problem that wouldn't have to be one if my coworker was simply allowed to call the endpoint from his code, but I found it interesting how simple it actually is to connect from a Python script to a local Outlook client and parse the results. Less than 100 lines of code, and we have a "build pipeline" going that reduces our manual overhead significantly.
slyiscoming@reddit
This is so terrible it's amusing. There must be at least a hundred better solutions to share those files.
That said, all of the Microsoft Office apps have extensive APIs. Years ago I wrote an app that dynamically created PowerPoint presentations and the API made it very easy
hennell@reddit
This is complete madness, an awful insane solution and I understand entirely.
The one thing with hacks like this is that if it is working around a problem that problem is now fixed and will never get solved. If the underlying issue of permissions is something that should be fixed, automate nagging for the real solution too. When you send a message to the end point also send a message to whoever is ment to give permissions to note that "you" just had to manually upload a patch because permissions aren't fixed yet. Randomise the subject to so it's harder for them to ignore then they/you won't forget about the issue and this hack won't be around forever...
SadInstance9172@reddit
This is the way. Ive used free gmail accounts instead of a "proper" message broker before. Works really well
codingtofreedom@reddit (OP)
Now that I think about it, that's how a lot of the low-code automations I've seen get triggered đ¤
All_Work_All_Play@reddit
Someone once told me "The two systems don't need to be connected through an API, they just need to look like they're connected through an API".
And that's how the MVP for a credit monitoring service of a half billion dollar shipping company ended up using email to look like the two different systems were talking to each other.
goomyman@reddit
I keep saying this. Outlook should have a database option.
Email as database. Your personal email.
Thatâs how people use it all the time.
Something like send an email - with a specific custom title or some tag. And it gets stored differently than email in some type of indexed database.
This would reduce 95% of work email IMO.
Nobody wants an email for every update of an incident. They just find email more convenient to read and filter and search. You know database functionality.
Outlook for should âemail as dataâ thatâs done just directly as an email. But not just filtered, indexed and stored differently than email - treated as data for personal use.
And it should be automatic for public use - right now every person is encouraged to send emails to everyone and itâs up to the user to filter it into the void never to be seen again. Instead - email as database can be stored centralized with runtime load that looks like an email. User wouldnât know itâs not just an email.
This could save massive amounts of spam. 99% of work emails are this garbage- incase the 1% might want to search something sometime.
brunogadaleta@reddit
Since the days I used Ftpmail to download Linux ISO, I realized that no-so-modern mail protocols are like every other protocols.
Which lib do you use? Can you share the code?
codingtofreedom@reddit (OP)
Directly via pywin32. Not sure how well the code copies over here, but the interesting bits were this how to connect to your inbox:
And then this here to filter for the newest unread message that fits the subject line in the right folder:
And then finally this is how to access the attachments of that email:
larsga@reddit
Why use Outlook instead of connecting to the mailbox directly over IMAP/POP3?
em__jr@reddit
If the OP's backend mail server is Exchange, it may not have been configured for IMAP/POP3.
Outlook's COM Object model, which the OP accessed through pywin32, is a relatively thorough API. It was designed for purposes like this Python script.
It's certainly an interesting workflow, no doubt!
flanger001@reddit
If it seems stupid, but it works, it isn't stupid.
i_dont_know@reddit
Curious if this is the ânewâ or âclassicâ outlook clients? Windows or macOS? Are these python bindings that Microsoft released?
codingtofreedom@reddit (OP)
It's the Classic outlook hosted on prem as a desktop client, from what I can tell the new version is no longer a desktop client and doesn't expose COM interface? On Windows using pretty standard connectors, but now that you mention it that might not work with current gen outlook the same way. I took a quick dive and it seems that new Outlook has to be set up with OAuth access and stuff, I guess that would turn the quick hack into taking more time than its worth.
arpan3t@reddit
Assuming youâre using M365 since youâre using Outlook as your mail client; you should look at Graph change notifications. You can subscribe to change events on various M365 resources like when a message is received by a mailbox.
The benefit being that you donât need to have your workstation running with Outlook like your solution.
I used it to set up a solution for our IT ops that takes a .heic image attachment from a received email â> converts it to .png â> replies with the .png attached.
They get a bunch of emails asking to âopenâ the .heic attachment from users that get emailed images taken from iOS devices, because Windows doesnât natively support the format.
beyphy@reddit
If Microsoft Graph isn't an option for whatever reason, you could also look into Logic Apps or Power Automate. I think both are just a GUI layer over Microsoft Graph.
arpan3t@reddit
Good option too! One thing to note is that the trigger for when new email arrives is limited to 50Mb total email size.
If Exchange admin has increased the max send/receive size for your mailbox, and the file being sent is > 50Mb, then Power Automate and Logic Apps wonât work.
PerceptionDistinct53@reddit
Jokes on you, now op will have to go through the bureaucracy mess to access his own outlook via Graph API.
arpan3t@reddit
lol well there is that!
Fr though, unless admins blocked it, they should have permissions to their own resources.
I would be so embarrassed if I found out one of our devs had to build OPs solution just because network admin wouldnât/couldnât setup a route.
codingtofreedom@reddit (OP)
Yes it's a bit of bureaucracy getting in the way, I hope it comes off as tongue in cheek because I expect the access to be given any day now, it just takes long and we are already developing on the tool so it just overlaps. We are hierarchically part of different teams so the approval has to go through an actual process which just takes time.
arpan3t@reddit
As long as the reasoning is sound, Iâm all for policies and procedures! Good on you for making it work with what you have available to you!
monty_mcmont@reddit
HERESY! I admire your creativity though đĽ´
Dizzy-Revolution-300@reddit
Why is the contrast so awful? Light gray on white backgroundÂ
codingtofreedom@reddit (OP)
Really? I am using a dark mode plugin for all sites anyway (highly recommend: dark reader), but I just disabled it and it looks fine to me, white on dark background đ¤
Dizzy-Revolution-300@reddit
https://i.imgur.com/aYebiVJ.png this is how it looks for my on firefox mobile
codingtofreedom@reddit (OP)
The fix was simple, I just had to force the desktop theme on mobile. I just checked on my phone and it seems to look good, thanks again for letting me know.
Dizzy-Revolution-300@reddit
Works for me now! I think some padding + font-size could be adjusted, but it's readable now, thanks!
codingtofreedom@reddit (OP)
Thanks for reporting, I'll investigate. I haven't actually tested the theme on mobile, I'll see if I can fix that.
ScriptingInJava@reddit
Interesting post, title would be a very fitting one for /r/programmingcirclejerk
Another post of yours caught my attention, had a read through and was hoping you'd be willing to share the updated version of the script linked at the top? Couldn't see a version of it available beyond the initial one in the thread on the AHK forum, would be super handy. Thanks!
codingtofreedom@reddit (OP)
Thank you! Here, see if this works for you, sorry but I threw out all my corrections, lots of personal stuff in there but it should work and allow you to add your own: https://pastecode.io/s/oah5q334
If you manage to get it working, can you get back to me? Then I'll add it to the post for everyone, I just realized that I forgot I wanted to do that.
ScriptingInJava@reddit
Wow yep, just outright worked. Did need to install v1.37.XXX (marked as deprecated on the AHK site) but ran the script and boom, instantly available. Really appreciate it, thanks.
codingtofreedom@reddit (OP)
Perfect, thanks for testing! I'll add the script to the post.
ScriptingInJava@reddit
Makes sense, thank you! I'll give it a spin now, if I make any changes I'll keep track of them so you have a "whitelabeled" one for your post.
FoeHammer99099@reddit
It taking weeks for someone's firewall privileges to get applied is the kind of problem you can throw managers at. If my skip learned that we we had to hack together our own solution after weeks of a manual process, heads would roll.
Redtitwhore@reddit
I remember way back when you could write vbscript directly in the email client. I would send myself emails with commands, they would get run on my computer and email me back the results.
codingtofreedom@reddit (OP)
You know, that's what I actually researched the other day to auto-generate JIRA tasks, that was one of the first projects I did as a junior dev, I think it was Excel VBA that called an endpoint using some deprecated method. Sadly, our access to those is locked down via company rule đ I have good memories of that setup, even though vbscript is paiiiiiinful to write đ
SpringDifferent9867@reddit
Did something similar many years ago to be able to run code on remote stations. UUCP is often thought of as just the predecessor to SMTP but it was a full unix to unix copy and execution protocol.
elsatan666@reddit
This is really interesting, I hadnât heard of UUCP before, thanks!
codingtofreedom@reddit (OP)
That sounds fun
SpringDifferent9867@reddit
Fun or challenging? đ
We did not have live internet from end to end at the time. Often routers used dial-up a few times a day, some even shutdown after each work day and during weekends, so âtelnetâ was not an option.
We could have used long distance calls (to great expense) but instead we used UUCP to issue a command and then maybe a week later the message would have travelled through the entire route and the first remote stations would start to do something.
yotemato@reddit
Fascinating. Did this cause any increased packet loss?
SpringDifferent9867@reddit
UUCP is (like SMTP) a store-and-forward protocol. If the message doesnât end in its complete form at the end of the route, it will time-out and the error will start its merry way back.
So any packet loss would be invisible to us but we would know if something bad happened. if that is what you asked? đ
samfynx@reddit
Usenet reinvented.
walmartbonerpills@reddit
I've seen Jenkins used for managing batches. I love seeing how non devs use dev tools.