PDA

View Full Version : Reporting backup automation



Michal
06-11-2015, 09:43 AM
Hello,

In my team we are getting 4 emails daily witch we need to review and report if everything is ok with backups.

Everyday we are looking for 8 string in 4 emails full of irrelevant info. If strings are there we need to send an report email that everything is ok.

I'm trying to automate it, but I don't know how to approach it.

I know how to run a script using outlook rules. Then I will need to collect information of strings somewhere and at the end of the day send an email that's everything is ok or not.

Is that can be done with outlook VBA? Any advises suggestions?

Thank You

Michal :)

Michal
06-11-2015, 12:08 PM
Hi again,

I already figured out how to search email body for strings I like and do something wit them



Public Sub process_email(itm As Outlook.MailItem)

Dim lonparch01 As String
lonparch01 = "*pnwifsvbbup03.r3-core.r3.aig.net:/root_vdm_1/vol_lonparch01_snap 42927:nsrndmp_save: Successfully done*"

Dim new_msg As MailItem
If itm.Body Like "*Savegroup: VNX_UK_NDMP_00:01 completed*" Then
If itm.Body Like lonparch01 Then
MsgBox ("vol_lonparch01_snapSuccessfully done")
Else:
MsgBox ("EPIC FAIL")
End
End If
End If
End Sub




Now I need to figure out how to create an email out of data form 4 email and send it after last email arrive.

Maybe there's a way to update message after every script run ale send it after 4th iteration.

Please advise.

Thank Michal :)

gmayor
06-11-2015, 10:08 PM
It is easy enough to create an e-mail message in place of your msgbox in the quoted code, but something seems to have been lost in the translation with


Now I need to figure out how to create an email out of data form 4 email and send it after last email arrive.
Maybe there's a way to update message after every script run ale send it after 4th iteration.

Can you clarify what that means?

Michal
06-12-2015, 01:55 AM
Oh sorry for my bad English,

I could send email every time the one of 4 report email reports arrive. But I want to send one after the last one that will arrive and I want it to contain full simplified report from all 4 emails.

I don't know how to collect data and send them out. Maybe good approach is creating and updating msg file but I have no idea how to do it.


Thank You Michal :)

Michal
06-12-2015, 08:27 AM
Hi Folks :)

I found the way to amend text file. But when I put everything in the subs it stopped working.

please advise:



Public Sub AppendTextFiles(safeset As String)
Open "C:\AppSupport\testfilew.txt" For Append As #1
Print #1, safeset
Close #1
End Sub
Public Sub CheckSafeSet(safeset As String) 'debbuger shows an issue here (its highlights it in yellow)
MsgBox ("1")
If itm.Body Like safeset Then
Call AppendTextFiles(safeset)
Else:
MsgBox ("FAIL")
End If
End Sub

Public Sub process_email(itm As Outlook.MailItem)
'Strings - Savegroups
Dim d1000i As String
Dim d1200i As String
Dim l0001i As String
l0001i = "*Savegroup: VNX_UK_NDMP_00:01*"
Dim l2000i As String

Dim lonparch01 As String
'lonparch01 = "*pnwifsvbbup03.r3-core.r3.aig.net:/root_vdm_1/vol_lonparch01_snap 42927:nsrndmp_save: Successfully done*"
lonparch01 = "*NDMP*"
Dim new_msg As MailItem
If itm.Body Like l0001i Then

Call CheckSafeSet(lonparch01)
Else:
End If

End Sub