Link to home
Start Free TrialLog in
Avatar of netcmh
netcmhFlag for United States of America

asked on

Outlook macro

I would like a weekly scheduled report generated automatically.

I receive in a folder (TransferLog) emails of the same format with varying pieces of data.

Example email body:
--------------------------------
The file Doc123.doc has been transferred by FTP into the Incoming folder

To: abc@abc.com
--------------------------------

I would like a macro to run every Friday night at 5pm that would look inside the TransferLog folder, go through each of the email, gather a few variables and consolidate it all into one email to myself.

The email could look like this:

<date> <time> Doc123.doc FTP Incoming abc@abc.com
<date> <time> Doc1323.zip SFTP Incoming yudg@abc.com
<date> <time> Zip45.txt FTP Incoming jhhd@abc.com
<date> <time> std33.jpg SCP Incoming jhdj2@abc.com

The <date> and <time> variables are gathered from the timestamp of the emails.
The filenames could be the same or different, but will always be the 3rd object in the first line.
The mode of transfer (FTP,SCP,SFTP) could be the same or different, but will always be the 8th object in the first line.
The foldername could be the same or different, but will always be the 11th object in the first line.
The To field could be the same or different, but will always be the 2nd object in the next line.

Can some one please help with the script required to do this?

Thank you.
Avatar of David Lee
David Lee
Flag of United States of America image

Hi, netcmh.

I might be able to help, but to determine that I really need to see what the body of one of these emails looks like.
Avatar of netcmh

ASKER

Thank you BlueDevilFan.

Here's what you asked for:
---------------------------------------

The file Сopy_of_Document_ID0500.zip has been transferred by FTP into the Incoming Folder, and has been logged.

Original Message:

  Date: Wed, 20 Aug 2014 00:32:46 -0700
  Subject: Urgent notice
  From: online_support@florida.gov
  To: <Radams@domain.org>

---------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
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
Avatar of netcmh

ASKER

Thanks.

When running the script, I got the Windows Script Host popup
Line:47
Char:1
Error: Expected Statement
Code: 800A0400
Source: Microsoft VBScript compilation error

I was hoping to write a macro in outlook.
Sorry, that's my fault.  Delete line 47.
I can write the macro to run inside of Outlook, but Outlook does not have a built-in means of scheduling a macro to run at a certain time.  Windows does and since you wanted this to run on a schedule I wrote it to run outside of Outlook where it can use Windows' built-in task scheduler.  I can rewrite it to run from inside of Outlook, but to make that work requires more code.  More code means a greater chance of problems.  It's your call.
Avatar of netcmh

ASKER

Line:17
Char:1
Error: Object required
Code: 800A01A8
Source: Microsoft VBScript compilation error
Almost certainly means that the path is invalid.  Did you edit the path?  If so, are you certain it's correct?
Avatar of netcmh

ASKER

So, if the folder is :

Inbox\Transfers\TransferLog

My path would be :

Const FOLDER_PATH = "Inbox\Transfers\TransferLog"

or

Const FOLDER_PATH = "Transfers\TransferLog"
The path needs the name of the store at the beginning.  For example

"someone@company.com\Inbox\Transfers\TransferLog"

or

"Mailbox - Doe, John\Inbox\Transfers\TransferLog"

or

"Personal Folders\Inbox\Transfers\TransferLog"

It depends on which version of Outlook you're using and where the folder is located.
Avatar of netcmh

ASKER

Wow, this works. Thank you.

If I were to invoke verbose logging on the transfers, the 6th line's 2nd word is of interest to me.

Can I modify the arrWrd = Split(arrLin(2)) variable to arrWrd = Split(arrLin(6)) and have it pick up the variable?
You're welcome.

Close.  Change it to

arrWrd = Split(arrLin(5))

The array starts at element 0 so the sixth line is the 5th element in the array.