VB Snippets - gregstretton/Transfer GitHub Wiki
Sub GetLatestSmokeTestsFromNas(Item As Outlook.MailItem)
Call Shell("G:\path\name.bat")
End Sub
Sub SendNew(Item As Outlook.MailItem)
'Call Shell("G:\path\name.bat") Dim Body As String Body = Item.Body Subject = Item.Subject BuildNumber = Split(Split(Subject, "EDMatterRoom_")(1), " succeeded")(0) SplitBody = Split(Split(Body, "Completed")(0), "Request ")(2) BuildRequestor = MultilineTrim(Mid(SplitBody, 8, Len(SplitBody))) BuildRequestorMailId = GetEmailByName(BuildRequestor) 'MsgBox "BuildRequestor:" & BuildRequestor 'MsgBox ("G:\path\name.bat " & BuildNumber & " " & Chr(34) & "BuildRequestor" & Chr(34) & "/ReqMailId:" & BuildRequestorMailId) & " " & Chr(34) & BuildRequestorMailId & Chr(34) Call Shell("G:\path\name.bat " & BuildNumber & " " & Chr(34) & BuildRequestor & Chr(34) & " " & Chr(34) & BuildRequestorMailId & Chr(34)) End Sub
Function MultilineTrim(ByVal TextData) Dim textRegExp As New RegExp textRegExp.Pattern = "\s{0,}(\S{1}[\s,\S]*\S{1})\s{0,}" textRegExp.Global = False textRegExp.IgnoreCase = True textRegExp.MultiLine = True
If textRegExp.test(TextData) Then
MultilineTrim = textRegExp.Replace(TextData, "$1")
Else
MultilineTrim = ""
End If
End Function
Function GetEmailByName(RequestorName) As String Dim xlApp As Object Dim sourceWB As Workbook Dim sourceWS As Worksheet 'Dim RequestorName As String
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Visible = False
.EnableEvents = False
End With
RequestorMailId = "[email protected]"
strFile = "G:\name.xls"
Set sourceWB = Workbooks.Open(strFile, , False, , , , , , , True)
Set SourceWH = sourceWB.Worksheets("NameEmailMap")
sourceWB.Activate
Set Found = SourceWH.UsedRange.Find(RequestorName)
If Found.Row <> 0 Then
RequestorMailId = SourceWH.Cells(Found.Row, 2)
End If
sourceWB.Close
GetEmailByName = RequestorMailId
End Function
'WScript.Arguments.Item(0) = Start / Completed 'WScript.Arguments.Item(1) = Test Name 'WScript.Arguments.Item(2) = Output Location 'WScript.Arguments.Item(3) = Environment 'WScript.Arguments.Item(4) = Build Number 'WScript.Arguments.Item(5) = Build Requestor 'WScript.Arguments.Item(6) = Build Requestor email Id
Set MyEmail=CreateObject("CDO.Message")
MyEmail.From="[email protected]"
'If this is a start of a run If WScript.Arguments.Item(0) = "Started" Then If WScript.Arguments.Item(3) = "QED" Then MyEmail.To="[email protected]; [email protected]; [email protected]" MyEmail.Subject="SoapUI - '" + WScript.Arguments.Item(1) + " - Run Started"
ElseIf WScript.Arguments.Item(3) = "CI" Then
MyEmail.To="[email protected]; " + WScript.Arguments.Item(6)
'MyEmail.To="[email protected]"
MyEmail.Subject="SoapUI - '" + WScript.Arguments.Item(1) + "' Build # " + WScript.Arguments.Item(4) + " Build Requested By - " + WScript.Arguments.Item(5) + " - Run Started"
ElseIf WScript.Arguments.Item(3) = "DEMO" Then
MyEmail.To="[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]"
MyEmail.Subject="SoapUI - '" + WScript.Arguments.Item(1) + " - Run Started"
End If
MyEmail.TextBody="SoapUI Test Runner has Started running '" + WScript.Arguments.Item(1) + "'. After the run completes, the results should be available at " + WScript.Arguments.Item(2) + " . Please use your TLR/TEN credentials to access the link."
'If this is the end of a run
ElseIf WScript.Arguments.Item(0) = "Completed" Then If WScript.Arguments.Item(3) = "CI" Then
MyEmail.To="[email protected]; [email protected]; [email protected]; " + WScript.Arguments.Item(6)
'MyEmail.To="[email protected]"
MyEmail.Subject="SoapUI - " + WScript.Arguments.Item(1) + " Build # " + WScript.Arguments.Item(4) + " Build Requested By - " + WScript.Arguments.Item(5) + " - Run Completed"
'Read the overview-summary.html file's contents.
MyEmail.CreateMHTMLBody WScript.Arguments.Item(2) + "overview-summary.html"
'Find the Test Failure HTML File path.
FailureFilePath = WScript.Arguments.Item(2) + "alltests-fails.html"
'Read the package-summary.html file's contents.
Set filestreamIN = CreateObject("Scripting.FileSystemObject").OpenTextFile(FailureFilePath,1)
FailureHTML = filestreamIN.ReadAll()
filestreamIN.Close()
'Make and HTML with the full HTML body.
MyEmail.HtmlBody = "<h2>Hello eDP</h2><p>SoapUI Test Runner has completed running '" + WScript.Arguments.Item(1) + "'. Below is the summary of the run. Detailed results are available at " + WScript.Arguments.Item(2) + "index.html . Please use your TLR/TEN credentials to access the link.</p>" & MyEmail.HtmlBody & FailureHTML
ElseIf WScript.Arguments.Item(3) = "DEMO" or WScript.Arguments.Item(3) = "QED" Then
'MyEmail.To="[email protected]; [email protected]"
MyEmail.To="[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected];"
MyEmail.Subject="SoapUI - " + WScript.Arguments.Item(1) + " - Run Completed"
'Read the overview-summary.html file's contents.
MyEmail.CreateMHTMLBody WScript.Arguments.Item(2) + "overview-summary.html"
'Find the Package Summary or the Test Suite report File path.
SummaryFilePath = WScript.Arguments.Item(2) + "Cayman EDMR Project\package-summary.html"
'Read the package-summary.html file's contents.
Set filestreamIN = CreateObject("Scripting.FileSystemObject").OpenTextFile(SummaryFilePath,1)
SummaryHTML = filestreamIN.ReadAll()
filestreamIN.Close()
'Make and HTML with the full HTML body.
MyEmail.HtmlBody = "<h2>Hello eDP</h2><p>SoapUI Test Runner has completed running '" + WScript.Arguments.Item(1) + "'. Below is the summary of the run. Detailed results are available at " + WScript.Arguments.Item(2) + "index.html . Please use your TLR/TEN credentials to access the link.</p>" & MyEmail.HtmlBody & SummaryHTML
End If
End If
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'SMTP Server MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="relay.int.westgroup.com"
'SMTP Port MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
MyEmail.Configuration.Fields.Update MyEmail.Send
set MyEmail=nothing