Avatar of pkromer
pkromer asked on

trim actual characters off string, send mail

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

Open in new window

Visual Basic ClassicVisual Basic.NET

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Fernando Soto

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes