Quantcast
Viewing latest article 1
Browse Latest Browse All 4

Answer by STTR for How to send rich text to the clipboard from command line?

Use e-mail CSS! Use UTF8 encoding html file!

Run http (HTML-eMail.html) e-mail from comman line:

powershell .\mail-http.ps1

mail-http.ps1:

$time = get-date 

$from    = 'So.From@gmail.com'
$to      = 'So.To@gmail.com'
$subject = 'eMail-HTML ' + $time

$server=smtp.gmail.com;$port=587

$encoding = [System.Text.Encoding]::UTF8

$email=new-object Net.Mail.MailMessage($from, $to, $subject, $body)
$email.DeliveryNotificationOptions=[System.Net.Mail.DeliveryNotificationOptions]::Delay
$email.IsBodyHtml = $true
$email.Priority = [System.Net.Mail.MailPriority]::High

$email.BodyEncoding=$encoding

$email.Body = gc '.\HTML-eMail.html' -encoding UTF8

$smtp=new-object Net.Mail.SmtpClient($server,$port)
$smtp.EnableSSL = $true
$smtp.Timeout = 30000  #ms
$smtp.Credentials=New-Object System.Net.NetworkCredential($from, 'derParol'); 

$smtp.Send($email)

HTML-eMail.html:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

...

</html>

Viewing latest article 1
Browse Latest Browse All 4

Trending Articles