unicav
02-09-2011, 10:57 AM
Greetings all and let me say up front I'm an IT not a programmer, but I have to dabble in everything from bash to vbs with some projects. I normally can work something out with a little direction but so far I'm hitting a brick wall on this and I hope someone here can help. Please forgive me if I'm long winded here but I want to try and fully explain what's going on and what my goal is.
I am using a vba to save attachments from emails to specific folders. I have several email addresses that are used by sites to send us documents for archiving. The email addresses correspond to their areas and the type of document. The VBA has subroutines for each email account and I use a message rule for each account to fire the VBA and have the attachments saved to the correct directory. That's fine for the first 4-5 accounts that simply dump the PDF's into the proper directory. The remaining accounts require splitting the incoming PDF's into separate TIF pages for an automated system to analyze. I have a python script that handles that and it takes a couple arguments from the VBA, the Source File and the Destination Directory. What's bothering me is I'm winding up with a dozen message rules and a dozen subroutines in the VBA to handle everything. It's messy and redundant and I know there's a better way to handle it. But then again we're talking about VBA right?
What I want to do is find a way to look at the account that received the email, or look at the recipients list of the email, and use that to build an IF or CASE statement to determine the Destination Directory and if the python script needs to be called. Then I would only need one rule and one subroutine in the VBA. The problem is 99% of the discussions and examples I've found on the internet are geared toward sending mail, not receiving it, and the bits of code I've found relating to the recipients list are longer than my whole VBA with all it's subroutines.
So can anyone point out what I'm missing or is it simply going to be easier to just keep adding rules and subroutines to handle everything?
I am using a vba to save attachments from emails to specific folders. I have several email addresses that are used by sites to send us documents for archiving. The email addresses correspond to their areas and the type of document. The VBA has subroutines for each email account and I use a message rule for each account to fire the VBA and have the attachments saved to the correct directory. That's fine for the first 4-5 accounts that simply dump the PDF's into the proper directory. The remaining accounts require splitting the incoming PDF's into separate TIF pages for an automated system to analyze. I have a python script that handles that and it takes a couple arguments from the VBA, the Source File and the Destination Directory. What's bothering me is I'm winding up with a dozen message rules and a dozen subroutines in the VBA to handle everything. It's messy and redundant and I know there's a better way to handle it. But then again we're talking about VBA right?
What I want to do is find a way to look at the account that received the email, or look at the recipients list of the email, and use that to build an IF or CASE statement to determine the Destination Directory and if the python script needs to be called. Then I would only need one rule and one subroutine in the VBA. The problem is 99% of the discussions and examples I've found on the internet are geared toward sending mail, not receiving it, and the bits of code I've found relating to the recipients list are longer than my whole VBA with all it's subroutines.
So can anyone point out what I'm missing or is it simply going to be easier to just keep adding rules and subroutines to handle everything?