troubleshooting Question

trim actual characters off string, send mail

Avatar of pkromer
pkromer asked on
Visual Basic ClassicVisual Basic.NET
1 Comment1 Solution194 ViewsLast Modified:
I have the following code which works well except I need to trim the following off the output...
<LOC>LeaveThisStuff</LOC>

So I need to leave everything between <LOC> and </LOC>, and it needs to send that via the email funtion here (which is currently working). In other words, the only thing not working is that the returned string has that extra data in every one of them that I don't want. Thank you.
Private Sub filediff()
 
Set poSendMail = New clsSendMail
 
Dim fso, f1, f2, file1, file2
Dim i, j, s, report
Dim found
Dim Diff1, Diff2
Dim d1, d2
 
file1 = "D:\Utilities\web_sitemap\sitemap.xml"
file2 = "D:\Utilities\web_sitemap\new\sitemap.xml"
 
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.OpenTextFile(file1, 1, 0)
Set f2 = fso.OpenTextFile(file2, 1, 0)
 
 
Do While f1.AtEndOfStream = False
      s = UCase(Trim(f1.ReadLine))
 
      If s <> "" Then
            d1.Add d1.Count, s
      End If
Loop
 
 
Do While f2.AtEndOfStream = False
      s = UCase(Trim(f2.ReadLine))
      If s <> "" Then
            d2.Add d2.Count, s
      End If
Loop
 
Diff1 = ""
Diff2 = ""
found = False
For i = 0 To d1.Count - 1
      found = False
      For j = 0 To d2.Count - 1
      
            If d1(i) = d2(j) Then
                  found = True
                  Exit For
            End If
      Next
      If Not found Then
            Diff1 = Diff1 + d1(i) + " "
      End If
Next
found = False
For i = 0 To d2.Count - 1
      found = False
      For j = 0 To d1.Count - 1
      
            If d2(i) = d1(j) Then
                  found = True
                  Exit For
            End If
      Next
      If Not found Then
            Diff2 = Diff2 + d2(i) + " "
      End If
Next
 
report = ""
If Diff1 <> "" Then
      report = "Found only in " & file1 & "  " & Diff1
End If
 
If Diff2 <> "" Then
      report = report & Chr(13) & Chr(10) & "Found only in " & file2 & "  " & Diff2
      poSendMail.SMTPHost = "MySMTPHost"
      poSendMail.from = "Me@MySite.com"
      poSendMail.FromDisplayName = "Admin"
      poSendMail.Recipient = "Me@MySite.com"
      poSendMail.RecipientDisplayName = "Company Staff"
      poSendMail.ReplyToAddress = "Me@MySite.com"
      poSendMail.Subject = "New URL on Website"
      poSendMail.Message = Diff2
      poSendMail.Send
End If
 
If report = "" Then
      MsgBox "No difference"
Else
      MsgBox report
End If
 
 
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros