I receive emails like this everyday:
The file Resume.docx has been sent with the subject Resume0213, and has been archived.
Date: Wed, 01 Oct 2014 13:42:25 +0100
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")
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>"
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. email@example.com
10/1/2014 02:32 Cover.txt Coverletter archived. firstname.lastname@example.org
10/1/2014 02:19 Resume.doc Resume for the post of - archived. email@example.com
As you can see, the To field is empty.
Please help me with this. Thank you.