Get values from e-mail

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
cacro790
Posts: 7
Last visit: Mon May 15, 2017 8:22 am

Re: Get values from e-mail

Post by cacro790 »

It was a colleague who left he company.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get values from e-mail

Post by jvierra »

The information you want is not in body.Text. It only exists in body.HTMLBody and will have to be parsed with RegEx.

Here is a partial dump of the HTML. It is about 120000 characters long and is attached as a file:

Code: [Select all] [Expand/Collapse] [Download] (Untitled.html)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>
  2.  
  3.     <title>Currency Update Service</title>
  4.     <style type="text/css">
  5.       .row1 {
  6.       background-color:#FFF;
  7.       }
  8.       .row2 {
  9.       background-color:#f2f5f7;
  10.       }
  11.     </style>
  12.   </head>
  13.   <body>
  14.     <div style="background-color:#f5f5f5">
  15.       <table width="634" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#6a6d70">
  16.         <tbody>
  17.           <tr>
  18.             <td width="5"></td>
  19.             <td align="center">
  20.               <div style="font-size:11px; text-align:center;">If this message is not displaying properly, <a href="http://www.us8.list-manage1.com/track/click?u=933cc770574d54135bec7d5f4&id=b3dfd9bd87&e=4e6b14fd6c" target="_blank">click here</a> to launch your browser.</div>
  21.             </td>
  22.             <td width="5"></td>
  23.           </tr>
  24.           <tr>
  25.             <td width="5"></td>
  26.             <td width="624" bgcolor="#FFFFFF">
  27.               <a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=08c2400eb9&e=4e6b14fd6c" target="_blank"><img src="http://www.xe.com/email/images/emailCUSHeader0808.jpg" width="624" alt="" border="0" title="www.xe.com"></a>
  28.               <table width="100%" cellpadding="0" cellspacing="0" border="0">
  29.                 <tbody>
  30.                   <tr>
  31.                     <td width="15"></td>
  32.                     <td>
  33.                       <p style="font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#6a6d70">
  34.                         Here is today's XE Currency Update for your personal use at home or work. For commercial use of our rates, try the <a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=8a573fa1f5&e=4e6b14fd6c" target="_blank">XE Datafeed</a>. If you like this service, <a href="http://www.us8.list-manage1.com/track/click?u=933cc770574d54135bec7d5f4&id=31983a4535&e=4e6b14fd6c" target="_blank">tell a friend</a>!
  35.                       </p>
  36.                       <div style="font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#002a7f;padding:6px;border:1px dotted #e5e5e5;">
  37.                         <strong><font color="#b98709">Send cheap money transfers with XE.&nbsp;</font></strong><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=86d693f5b1&e=4e6b14fd6c">Sign up now</a>&nbsp;<span style="font-size:10px"></span>
  38.                       </div>
  39.                       <p style="font-size:18px; font-family:Lucida Sans,Arial,Helvetica,sans-serif; color:#002d4d">
  40.                         XE Market Analysis
  41.                       </p>
  42.                                 <style type="text/css">
  43.                 a:link
  44.                 {
  45.                     color:#002a7f;
  46.                     text-decoration:underline;
  47.                 }
  48.                 a:hover
  49.                 {
  50.                     text-decoration:none;
  51.                 }
  52.                 a:visited
  53.                 {
  54.                     color:#002a7f;
  55.                 }
  56.                 .widgetsActionEconomics
  57.                 {
  58.                     margin-top: 10px;
  59.                     font-family: Arial,Helvetica,sans-serif;       
  60.                     font-size: 12px;
  61.                 }
  62.                 .widgetsActionEconomics .widgetContentList
  63.                 {
  64.                     margin-left: -40px;
  65.                     margin-top: -10px;
  66.                 }
  67.                 .widgetsActionEconomics .widgetContentList li
  68.                 {
  69.                     list-style:none;
  70.                     color: #002A7F;
  71.                     margin-bottom: 10px;
  72.                 }
  73.                 .widgetsActionEconomics .widgetContentList li:first-child
  74.                 {
  75.                     margin-top:20px;
  76.                 }
  77.             </style>
  78.             <div class="widgetsActionEconomics">
  79.                 <ul class="widgetContentList"><li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=74a6995672&e=4e6b14fd6c">XE Market Analysis: North America - May 11, 2017</a></li>
  80. </ul><ul class="widgetContentList"><li><a href="http://www.us8.list-manage1.com/track/click?u=933cc770574d54135bec7d5f4&id=2132cea716&e=4e6b14fd6c">XE Market Analysis: Europe - May 11, 2017</a></li>
  81. </ul><ul class="widgetContentList"><li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=5f284d386e&e=4e6b14fd6c">XE Market Analysis: Asia - May 11, 2017</a></li>
  82. </ul><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=06aeec2e36&e=4e6b14fd6c">More XE Commentary</a>
  83.             </div>
  84.                       <table width="604" border="0" cellspacing="0" cellpadding="0" align="center">
  85.                         <tbody>
  86.                           <tr>
  87.                             <td valign="top">
  88.                               <p style="font-size:18px; font-family:Lucida Sans,Arial,Helvetica,sans-serif; color:#002d4d; padding-top:15px">
  89.                                 Central Bank Interest Rates
  90.                               </p>
  91.                                         <style type="text/css">
  92.                 ul.bankRates {height: 39px; width:404px; margin-left:-40px; margin-top:-10px; }
  93.                 .bankRates li {display:inline-block; float:left; width:100px; font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#6a6d70; padding: 7px 0px}
  94.                 .bankRates li:nth-child(-n+4){background-color:#ffffff;}
  95.                 .bankRates li:nth-child(n+5){background-color:#f4f4f4;}
  96.                 .bankRates a {pointer-events:none; }
  97.                 .bankRates a:link, a:visited, a:active {color: #6A6D70;text-decoration:none;}
  98.                 .bankRates a:hover, a:focus {color: #777777;}  
  99.             </style><ul class="bankRates"><li><a href="http://www.us8.list-manage2.com/track/click?u=933cc770574d54135bec7d5f4&id=1a6fe58301&e=4e6b14fd6c"><span class="centralBankPopularCurrency">JPY</span> -0.10%</a></li>
  100. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=86c6324e9d&e=4e6b14fd6c"><span class="centralBankPopularCurrency">CHF</span> -0.75%</a></li>
  101. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=da3942bced&e=4e6b14fd6c"><span class="centralBankPopularCurrency">EUR</span> 0.00%</a></li>
  102. <li><a href="http://www.us8.list-manage1.com/track/click?u=933cc770574d54135bec7d5f4&id=ebb3887cf7&e=4e6b14fd6c"><span class="centralBankPopularCurrency">USD</span> 0.75%</a></li>
  103. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=4bfeda5c2c&e=4e6b14fd6c"><span class="centralBankPopularCurrency">CAD</span> 0.50%</a></li>
  104. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=fa1d98ee9c&e=4e6b14fd6c"><span class="centralBankPopularCurrency">AUD</span> 1.50%</a></li>
  105. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=1f866a0822&e=4e6b14fd6c"><span class="centralBankPopularCurrency">NZD</span> 1.75%</a></li>
  106. <li><a href="http://www.us8.list-manage.com/track/click?u=933cc770574d54135bec7d5f4&id=c630bff3aa&e=4e6b14fd6c"><span class="centralBankPopularCurrency">GBP</span> 0.25%</a></li>
  107. </ul>
  108.                                       </p>
  109.  
  110.     </div>
  111.   <img src="http://www.us8.list-manage.com/track/open.php?u=933cc770574d54135bec7d5f4&id=29838992f5&e=4e6b14fd6c" height="1" width="1"></body>
  112. </html>
Attachments
htmltext.txt
(230.42 KiB) Downloaded 99 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get values from e-mail

Post by jvierra »

cacro790 wrote:It was a colleague who left he company.
I recommend contacting a consultant to help with this as it requires fairly advance work. It cannot be don in 5 minutes. If you are not a proficient PowerShell scripter then you will not be able to fix this.
User avatar
cacro790
Posts: 7
Last visit: Mon May 15, 2017 8:22 am

Re: Get values from e-mail

Post by cacro790 »

Ok, thanks a lot for your help !
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get values from e-mail

Post by jvierra »

If you need to do this reliably then the vendor provides and API for direct download of data:

http://www.xe.com/xecurrencydata/
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked