Link to home
Start Free TrialLog in
Avatar of Nigel Keith-Walker
Nigel Keith-WalkerFlag for Australia

asked on

How can I send password protected files by email using VBA from MS Access

There is a business requirement to extract data to be loaded into MYOB at another, remote  office.  I have coded the extract (from an SQL 2008 database) which creates three files on a local computer.  

I would like to Zip these flies, password protect them and send them to the remote office.  The data is in the form of a csv file.  It is not very large, so Zipping is not essential.  The data is not hypersensitive, but commercial in confidence.  The office staff need to perform this at close of business, so I would like to automate the process.  But if anybody has a suggestion for using zip, I could make this a two button operation

1.

Extract the three files to the desktop

2.

Zip, password protect and email the files as an attachment
Avatar of Christopher Jay Wolff
Christopher Jay Wolff
Flag of United States of America image

Is it the specific VBA you're looking for, or just the right strategy to put into VBA and you're quite adept at VBA?  I figure if I can do it script, you can do it in VBA.

I wonder what version of Windows you're using.  I'm on 8.1 so cannot verify 7 or XP usage for passwords.  In 8.1 there is no built-in password usage so after ZIP, I select zipped folder in File Manager and I have a pull-down available for Select People.  This incorporates the users individual passwords and permissions for access to the zip folder.  Obviously, can use this method with other OS accessing permissions differently.  I read password protection is available in XP and 7 under the file pull-down in File Manager.  Although having it in 7 is circumspect since the user quoted in the excerpt below lists himself as a 7 user, but does not specifically say so in the thread.   I also understand if you use the password protection available in XP and 7 and forget the password, you're out of luck.  This make the permissions method more appealing, since admin can recover.

Do you use third party password protection?

Here is a link with a thread that pretty much sums up this password usage, and mentions most of the popular third party password protection products.  An excerpt follows.

http://www.sevenforums.com/general-discussion/209452-how-do-i-password-protect-folder-file.html

User generated image
And here is a blurb from Microsoft on Windows 7 which counters my investigations above.

http://windows.microsoft.com/en-us/windows/password-protect-files-folders#1TC=windows-7

Useful at all?
Avatar of Nigel Keith-Walker

ASKER

I had not thought of using permissions.  The sending office uses win7, I develop in Win 8.1.  But I do use WinZip, which has replaced the MS standard option in Windows explorer, so I have problems following through the standard Zip instructions.

I had been contemplating using the WinZip processes to zip, encrypt and email the three files.  Training the staff would require a one page cheat sheet.  

Alternatively, I am competent with VBA, and it would be neat to provide a one button process to extract, zip, encrypt and send.
Avatar of David Lee
Do you have WinZip's command-line utility installed?  If so, then you can call it from VBA, zip the files, password protect the zip file, then create an email attach the zip file, and send it off.
No.  It will require an update from ver 14 to ver 17+ which is not an issue.  Do you know if I have to have the Pro version or can I just update the standard version?
That I don't know.
After I get caught up with work, I may have time to look into this, but it sounds like your one button solution might be nice in powershell.  Threw some quick links in for you to review.  If you haven't used powershell it can be very helpful for this type of thing.  Please let us know what you think.


extract data
http://joshcodev.wordpress.com/2014/02/10/powershell-extract-data-from-a-database/



zip em up, see David's answer and follow-up comment about David's answer, don't miss other links
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/8f98f06e-79fe-401c-92f0-a548d4304dcc/how-to-zip-files-and-folders-using-powershell



two links about encrypting in Powershell
http://infoworks.tv/encrypt-files-and-folders-using-powershell-and-efs/

http://www.amandhally.net/2013/03/18/powershell-script-create-an-encrypted-folder-using-powershell/



email em.
Launch powershell window, type...
Get-Help Send-MailMessage -full

and you will see...
User generated image
I have not used powershell yet.  The extract has been written and tested in VBA, and is within the app that the backend user spends most of their day.  So the start point will be that three files, which could be in the same folder, are to be encrypted and sent.

I am in Australian time, so have just got up and quickly viewed the links.  I will need to think through the two options after breakfast.
I have taken advantage of an upgrade offer which arrived from WinZip yesterday to upgrade my version 15 std WinZip to WinZip 19 Pro for $AUD29-95.  This has allowed me to download the add-in for command Line support.  I am reading up the doco on using the command window.
ASKER CERTIFIED SOLUTION
Avatar of Christopher Jay Wolff
Christopher Jay Wolff
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, I read somewhere that if you use cipher.exe to encrypt a .zip file, Windows automatically unzips it first, then encrypts it.  So if that info is accurate, you may have to encrypt first then zip, but it may not apply at all if using WinZip.

Here are a couple links with zip scripts in Powershell.  The second link to zip approach looks pretty good but from 2006.  The EE link is this year.

https://www.experts-exchange.com/questions/28407343/Compress-a-file-via-PowerShell.html

http://mow001.blogspot.com/2006/01/msh-out-zip-function.html

and several approaches here...
https://www.experts-exchange.com/questions/28407343/Compress-a-file-via-PowerShell.html
Hi Christopher

This morning I had a discussion with the two business partners involved with the two offices involved.  We have decided that WinZip will be the application used to transfer the data.  Initially we will use a cheat sheet to use WinZip the files to the other office.  

Your links provide the opportunity to enhance the transfer process.  Initially we need to determine that the data will allow for a quicker reconciliation in MYOB.  Once we have established that this is an essential part of the COB routine, then I can justify extra enhancement.

I will be out of the office for the next two weeks.  I do not want you to be frustrated with a lack of response, so I am allocating the points now.   As a developer, I want to investigate how to use the powershell to send a command line to WinZip.  Perhaps I will do this in my own time.  I am sure that any other businesses have a similar scenario, and there are multiple possible solutions.

Regards from Australia
Thank you NIgel.

I see I pasted the same EE link in twice above by mistake.  Oh well, easy to search again.

Sounds like a great plan.  Yes, so many ways to do things.  May it go smoothly for you.

Cheers from where we had snow last night, Michigan, USA.