2016-10-03 94 views
0

我使用PowerShell通過腳本以西班牙語發送Windows Server 2008 R2中的電子郵件,但文本顯示不正確。PowerShell不能正確顯示西班牙語文本

這是MI代碼:

$file = "c:\Contenido-Mail.txt" 

if (test-path $file) 
{ 

    $from = "[email protected]" 
    $to = "<[email protected]>" 
    #Las direcciones del to deben indicarse con signos de mayor que 
    #y menor que. 
    $pc = get-content env:computername 
    $subject = "Mesaje de prueba del servidor " + $pc 
    $smtpserver ="192.168.4.133" 


    #Con Out-String formateamos el texto 
    $body = Get-Content $file | Out-String 


    foreach ($recipient in $to) 
    { 
     write-host "Enviando mail a $to" 
     Send-MailMessage -smtpServer $smtpserver -from $from -to $recipient -subject $subject -body $body 
    } 
} 
else 
{ 
write-host "Configuración" 
} 

下面是正文:

JUEGO德tronos ES UNA意甲德電視

和這裏(權力EN英語的遊戲)它在Outlook客戶端中的外觀如何:

JUEGO德tronos ES UNA系列德televisi(王座恩ingl?博弈)3 N

你認爲我做錯了什麼?

+0

嘗試用在獲取內容的命令編碼打..也許加上' - 編碼「ISO-8859-1」'什麼like那 –

回答

0

假設你的文本文檔的編碼是UTF8,試試這個:

$body = Get-Content $file -encoding UTF8 | Out-String 
+0

如何檢查我的文本文檔是否編碼爲UTF8?試試,但沒有奏效。謝謝! –

+0

你可以下載一個像Notepad ++這樣的文本編輯器來告訴你(並讓你切換哪種類型)。 – BenH

相關問題