title: How to send a chart as an email body using powershell
body: <p>i have the following code. this is used to compare two dates for data and then saves it in a 3D chart. </p>
  
  <pre><code>     [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
  $scriptpath = Split-Path -parent $MyInvocation.MyCommand.Definition
  
  # chart object
   $chart1 = New-object System.Windows.Forms.DataVisualization.Charting.Chart
   $chart1.Width = 1300
   $chart1.Height = 600
   $chart1.BackColor = [System.Drawing.Color]::White
  
  # title 
   [void]$chart1.Titles.Add("Order Rate")
   $chart1.Titles[0].Font = "Arial,13pt"
   $chart1.Titles[0].Alignment = "topLeft"
  
  # chart area 
  
  $chartarea3D = New-Object  System.Windows.Forms.DataVisualization.Charting.ChartArea3DStyle
  # $chartarea.Name = "ChartArea1"
  $chartarea3D.Enable3D = $true
  $ChartArea = $chart1.ChartAreas.Add('ChartArea');
  $ChartArea.Area3DStyle = $chartarea3D
  $chartarea.AxisY.Title = "Orders"
  $chartarea.AxisX.Title = "Hour"
  $chartarea.AxisY.Interval = 200
  $chartarea.AxisX.Interval = 1
  
  # legend 
  $legend = New-Object system.Windows.Forms.DataVisualization.Charting.Legend
  $legend.name = "Legend1"
  $chart1.Legends.Add($legend)
  
  # data source
  
  #region Invoke sql
  function Invoke-Sqlcmd2 
  &lt;some code&gt;
  
   #endregion 
   $datasource = Invoke-Sqlcmd2 -ServerInstance yyyyyy -Database     internetordering -Query "SELECT  DATEPART(hh,createdon) AS hour, Count(*)Orders from dbo.OrderHeader (nolock ) 
      where isimported = 1 and createdon between '01/27/2015 0:00:00' and '01/27/2015 23:59:59'
      group by DATEPART(hh,createdon)"
  
     $datasource2 = Invoke-Sqlcmd2 -ServerInstance zzzzzz -Database internetordering -Query "SELECT  DATEPART(hh,createdon) AS hour, Count(*)Orders from InternetOrdering.dbo.OrderHeader (nolock ) 
      where isimported = 1 and createdon between '01/28/2015 0:00:00' and '01/28/2015 23:59:59'
      group by DATEPART(hh,createdon)"
  
  
  # data series
  [void]$chart1.Series.Add("OrdersLastMonthEOM")
  #$chart1.Series["OrdersLastMonthEOM"].ChartType = "Column"
  $chart1.Series["OrdersLastMonthEOM"].ChartType = "Line"
  $chart1.Series["OrdersLastMonthEOM"].IsVisibleInLegend = $true
  $chart1.Series["OrdersLastMonthEOM"].BorderWidth  = 3
  #$chart1.Series["OrdersLastMonthEOM"].chartarea = "ChartArea1"
  $chart1.Series["OrdersLastMonthEOM"].Legend = "Legend1"
  $chart1.Series["OrdersLastMonthEOM"].color = "#62B5CC"
  $datasource | ForEach-Object  {$chart1.Series["OrdersLastMonthEOM"].Points.addxy( $_.Hour , $_.Orders) }
  
  # data series
  [void]$chart1.Series.Add("OrdersThisMonthEOM")
  #$chart1.Series["OrdersThisMonthEOM"].ChartType = "Column"
  $chart1.Series["OrdersThisMonthEOM"].ChartType = "Line"
  $chart1.Series["OrdersThisMonthEOM"].IsVisibleInLegend = $true
  $chart1.Series["OrdersThisMonthEOM"].BorderWidth  = 3
  #$chart1.Series["OrdersThisMonthEOM"].chartarea = "ChartArea1"
  $chart1.Series["OrdersThisMonthEOM"].Legend = "Legend1"
  $chart1.Series["OrdersThisMonthEOM"].color = "#E3B64C"
  $datasource2 | ForEach-Object {$chart1.Series["OrdersThisMonthEOM"].Points.addxy( $_.Hour , $_.Orders) }
  
  # save chart
  $chart1.SaveImage("$scriptpath\SplineArea2.png","png")
  </code></pre>
  
  <p>This creates a cool 3D Line graph on ISplineArea.png . I need a way to send this graph in a body of an email. Can anyone help with that. </p>