Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBScript Array help

Posted on 2014-10-01
4
229 Views
Last Modified: 2014-10-01
I receive emails like this everyday:

The file Resume.docx has been sent with the subject Resume0213, and has been archived.

Original Message:

  Date: Wed, 01 Oct 2014 13:42:25 +0100
  Subject: Resume0213
  From: abc@xyz.com
  To: <def@pqr.com>

I have a vbscript which when executed, would go through my emails in a particular folder and compile them, and would email me that output.

The relevant portion of the code is below:

strBuf = "<tr><td>Date</td><td>Time</td><td>File</td><td>Subject</td><td>Action</td><td>From</td><td>To</td></tr>"
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkFld = OpenOutlookFolder(FOLDER_PATH)
For Each olkMsg In olkFld.Items
    arrLin = Split(olkMsg.Body, vbCrLf)
    arrWrd = Split(arrLin(0), " ")
    strDat = FormatDateTime(olkMsg.ReceivedTime, vbShortDate)
    strTim = FormatDateTime(olkMsg.ReceivedTime, vbShortTime)
    strFil = arrWrd(2)
    strSub = arrWrd(9)
    strAct = arrWrd(13)
    arrWrd = Split(arrLin(6))
    strFrom = arrWrd(3)
    arrWrd = Split(arrLin(7))
    strTo = arrWrd(3)
    strBuf = strBuf & "<tr><td>" & strDat & "</td>" _
                    & "<td>" & strTim & "</td>" _
                    & "<td>" & strFil & "</td>" _
                    & "<td>" & strSub & "</td>" _
                    & "<td>" & strAct & "</td>" _
                    & "<td>" & strFrom & "</td>" _
                    & "<td>" & strTo & "</td></tr>"
Next

Open in new window



The problem I have is that the To: line has special characters < and >, which might be interfering with the script.

I recieve compiled emails like this:

Date            Time      File            Subject            Action            From            To
10/1/2014      08:41      Resume.docx      Resume0213      archived.      abc@xyz.com
10/1/2014      02:32      Cover.txt      Coverletter      archived.      abc@xyz.com
10/1/2014      02:19      Resume.doc      Resume for the post of -  archived.      tre@opt.com

As you can see, the To field is empty.

Please help me with this. Thank you.
0
Comment
Question by:netcmh
  • 2
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 40354571
Maybe

strTo = Replace(Replace(arrWrd(3), ">", "&gt"), "<", "&lt")
0
 
LVL 20

Author Comment

by:netcmh
ID: 40354584
Kinda worked.

I'm getting this in the To: Column now

&ltabc@xyz.com>

How do I get rid of the &lt and the > ?
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40354591
So maybe

strTo = Replace(Replace(arrWrd(3), ">", ""), "<", "")
0
 
LVL 20

Author Comment

by:netcmh
ID: 40354617
Thanks. That works.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
excel exchange 7 41
excel VBA - clear duplicates not working 11 37
a slight change to the code written by Brad Yundt 2 33
Button function on table is in trouble 3 22
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question