Sign in to follow this  
Followers 0
Jewtus

Create email with array in body

3 posts in this topic

#1 ·  Posted (edited)

I'm creating a script that goes to a web page, grabs the table from the webpage and sends it as an email and I feel like there has to be a better way to do this.

_IENavigate($oIE,$URL)
$oTable = _IETableGetCollection($oIE)
$iNumTables = @extended
$oMeta = _IETableGetCollection($oIE, 1) ; Extract main table
$aMeta = _IETableWriteToArray($oMeta, True)
$oMetaCount = _IETableGetCollection($oIE, 0) ; Extract main table
$aMetaCount = _IETableWriteToArray($oMetaCount, True)
$olApp = ObjCreate("Outlook.Application")
$olMailItem = 0
$objMail = $olApp.CreateItem($olMailItem)
$objMail.Save
$objMail.To =($contactemail)
$objMail.Subject = ("ThisIsATest")
For $q=0 to UBound($aMeta) -1
    $Holder= $aMeta[$q][0]&@TAB&$aMeta[$q][1]&@TAB&$aMeta[$q][2]&@TAB&$aMeta[$q][3]&@TAB&$aMeta[$q][4]
    $objMail.HTMLBody = ($Holder&@CRLF)
Next
$objMail.Display
$oOApp = 0

This script does most of what I need to, but it puts the body as just the last line in the array. I've also tried using:

Local $content
$objMail.HTMLBody = ($aMetaCount[0][1]&@CRLF)
For $q=0 to UBound($aMeta) -1
    $Holder= $aMeta[$q][0]&@TAB&$aMeta[$q][1]&@TAB&$aMeta[$q][2]&@TAB&$aMeta[$q][3]&@TAB&$aMeta[$q][4]
    $content= $content&@CRLF&$Holder
Next
$objMail.HTMLBody = ($content&@CRLF)
$objMail.Display
$oOApp = 0

But that gets rid of all the CRLF and Tabs. Does anyone know of a simpler way to write an array into an email?

Edited by Jewtus

Share this post


Link to post
Share on other sites



You have the array, correct? It is just an issue with putting the entire array into the email? Have you looked at _ArrayToString?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I did try array to string, which does improve how the code looks, but it does still ditch the CRLF and Tabs... then I realized I'm using HTMLBody and not Body...

It works fine with this:

$oTable = _IETableGetCollection($oIE)
$oMeta = _IETableGetCollection($oIE, 1) ; Extract main table
$aMeta = _IETableWriteToArray($oMeta, True)
$oMetaCount = _IETableGetCollection($oIE, 0) ; Extract main table
$aMetaCount = _IETableWriteToArray($oMetaCount, True)
$content= _ArrayToString($aMeta,@TAB,0,UBound($aMeta)-1)
$olApp = ObjCreate("Outlook.Application")
$olMailItem = 0
$objMail = $olApp.CreateItem($olMailItem)
$objMail.Save
$objMail.Body = ($aMetaCount[0][1]&@CRLF&@CRLF&$content)
$objMail.Display
$oOApp = 0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0