Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I work for a company in Belgium as the systems and network administrator.
A couple of years ago we've replaced our archiving software by some rubbish program that didn’t do what it was supposed to do.
After struggling with troubleshooting the application, I wrote a custom program to read the barcodes on the scanned documents and save the data to a MySQL database.
Long story short: link the order numbers to the correct documents based on the barcode.

As there is A LOT of mailing going on with the customer and internal departments, we’d like to archive mails in the same manner.
Now I was thinking of modifying our Exchange Online setup and adding a custom connector.
All mails that are being sent to DOESNTMATTER@archive.COMPANYNAME.com should be sent to a custom SMTP server (which runs on one of our servers).
This application then checks if DOESNTMATTER is an actual order number in our system.
If so ==> Convert the mail to a PDF (and also it’s attachments) and save the documents + write the document name and order number into the MySQL database.
If not ==> park the mail in some folder, where I can then manually control and correct.

Do you guys think this could be achieved with a c-sharp application?
My biggest struggle is the actual SMTP server. Creating the Exchange connector and handling the actual mails that are coming isn’t a problem.

Thanks for your reply!

What I have tried:

Nothing much really, been looking to find similar projects to help me on my way, but nobody seems to have the same needs :-(
Posted
Comments
[no name] 25-Oct-21 15:16pm    
If you dump the incoming emails to disk, then you can use a C# program with a "FileSystemWatcher" to pick up (and convert) the new mail.

https://github.com/snsttr/smtp-dump
DerekT-P 28-Oct-21 7:47am    
I've not done this by writing a custom SMTP server; however, I do have a similar process in production now. Mails are sent to a predefined (single) mailbox, with (in my case) a vehicle registration number as the subject line. I have a periodic (every 15 minutes) process that reads all mail in that mailbox (I use the MailKit component from .Net Foundation), parse it (using MimeKit), fetch corresponding data from the d/b (based on the subject line) and then do stuff with the mail content. (If it's HTML format, you could use something like Pechkin to save it as a PDF).
In your scenario I guess you need to keep the original subject line, but as you have a whole subdomain for this, you can setup a "catchall" email account and include your reference as the mailbox name as you suggest. In my case I've just got a standard hosted domain and have added an IMAP mailbox for the purpose. In fact as the whole shooting match is on a cheap hosted webserver, the periodic process is actually just a webpage that gets invoked via Plesk's scheduled tasks feature (or I could use an external Cron job to trigger it). It's run for 6months+ now without issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900