netcmh
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.
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.
ASKER
Thank you BlueDevilFan.
Here's what you asked for:
-------------------------- ---------- ---
The file Сopy_of_Document_ID0500.zi p 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>
-------------------------- ---------- ---
Here's what you asked for:
--------------------------
The file Сopy_of_Document_ID0500.zi
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
Line:17
Char:1
Error: Object required
Code: 800A01A8
Source: Microsoft VBScript compilation error
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?
ASKER
So, if the folder is :
Inbox\Transfers\TransferLo g
My path would be :
Const FOLDER_PATH = "Inbox\Transfers\TransferL og"
or
Const FOLDER_PATH = "Transfers\TransferLog"
Inbox\Transfers\TransferLo
My path would be :
Const FOLDER_PATH = "Inbox\Transfers\TransferL
or
Const FOLDER_PATH = "Transfers\TransferLog"
The path needs the name of the store at the beginning. For example
"someone@company.com\Inbox \Transfers \TransferL og"
or
"Mailbox - Doe, John\Inbox\Transfers\Trans ferLog"
or
"Personal Folders\Inbox\Transfers\Tr ansferLog"
It depends on which version of Outlook you're using and where the folder is located.
"someone@company.com\Inbox
or
"Mailbox - Doe, John\Inbox\Transfers\Trans
or
"Personal Folders\Inbox\Transfers\Tr
It depends on which version of Outlook you're using and where the folder is located.
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?
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.
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.
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.