Autosave attachment and create text file based on information in email.

R

rligouri

I use a document imaging system that uses OCR to file documents I scan
into it. For every document I scan in, I have to print a "lead sheet"
that contains the document information (file number, document type). I
use the lead sheet as the first page of the document I am scanning and
my system will use OCR to read the info on the lead sheet and it will
file it based on that info. Problem is the OCR runs into too many
problems. If the lead sheet isnt perfectly straight, the ink too light,
there is a mark on the scanner or many others, the document will not
file properly. I contacted my software vendor and they said they will
come up with an alternative and they added the ability for the system
to process metadata files. The metadata file is a file created by some
scanners when you scan a document that contains user inputted
information. I could input the file number and document type right from
the scanner and a .DAT file (metadata file) will accompany the scanned
file telling the system how to file document. Next problem is my
scanners do not have this feature.

I've brainstormed and I came up with an idea to create the metadata
file.Create an email with the document attached and the file
information in the subject line. Send the email to a computer with
outlook always running on it. Using a combination of rules and vba,
outlook will do the following:

1) Save the attachment to a specific directory. I need to target only
TIFF files as my that is the only format my system can handle.

2) Create a text file containing information from the subject line
and/or body and the attachment file name of the email and save it as a
..DAT file in the same directory as where the TIFF file was saved.

The metadata file has to be formated like
xxxxxxxxxYYYYYYYYYYYYzzzzzzzzzzzzz. With x being the file number, Y
being the document type, and z being the path of the TIFF file. The
file name need to be formatted as IT#.dat, with # being a random
generated number to avoid duplicates.

Any help would be greatly appreciated.
 
M

Michael Bauer [MVP - Outlook]

Am 1 Sep 2006 14:50:56 -0700 schrieb (e-mail address removed):

If you google for something like "auto save attachment", there should be a
lot of samples already.

That samples use the ItemAdd event of the Inbox. In that event you can also
parse the incoming item´s Subject and Body properties. Extract whatever you
want with the Instr and Left, Right or Mid functions.

For creating files and/or folders easily you could use the Microsoft
Scripting Runtime. Add a reference to it to your project, open the Object
Browser (F2) and select the FileSystemObject. In the right pane you can see
then all its methods.
 
R

rligouri

Thank you for the reply Michael. I was able to successfully create a
text file and play around with the formatting of the file name using
the FSO. I have played around with Access and Word VBA, but I am
totally new to Outlook VBA and really no clue what I am doing. I have
had no luck with including information from emails I receive in the
text file. I have looked around and I cannot find anything for exactly
what I need. Can you point me in the right direction "code wise"?

So far I have:

Sub CreateAfile()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\" & Format(Date, "mmddyy") &
Format(Time, "hhmmss") & ".dat", True)
a.WriteLine ("Text")
a.Close
End Sub

How do I pull information from the subject of the email to "Text"?

Also, can you recommend any good books for Outlook VBA? I want to pick
one up ASAP.
 
M

Michael Bauer [MVP - Outlook]

Am 4 Sep 2006 14:52:05 -0700 schrieb (e-mail address removed):

Here´s a sample for printing attachments as soon as they arrive:
http://www.vboffice.net/sample.html?mnu=2&smp=3&cmd=showitem

The sample also saves the attachments. Simply skip the almost last line,
oAtt.SaveAsFile sFile, which you don´t need. The method gets passed the
e-mail as argument, its Body e.g. you can get by reading oMail.Body.

Good books are e.g.:

- Absolute Beginner´s Guide to Microsoft Office Outlook 2003, Ken Slovak
- Microsoft Outlook Programming, Sue Mosher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top