複数の文がある場合、電子メールにテキストを追加するファイルは、文を正しく追加しません。ファイルの本文テキスト
コンテンツ@は空です。
署名を追加するだけです。
入力ファイル(名前:Text_file.txt
):
email:[email protected] emialcc: emailbcc: Subject:2513000013 attachment:Y:\attachment\2513000013.pdf
テキストファイル:
This is a test This and other lines do not show up test3 test4 test5
PowerShellスクリプト:
$destDir = "C:\M3_Outlook"
if (!(Test-Path $destDir)) {
New-Item -Path $destDir -ItemType Directory
} else {}
$file_patch = Get-ChildItem 'C:\M3_Outlook' | Sort {$_.LastWriteTime} |
select -Last 1 | % { $_.FullName }
$name = Select-String -Path $file_patch -pattern name
$email = Select-String -Path $file_patch -pattern email
$subject=Select-String -Path $file_patch -pattern subject
$attachment = Select-String -Path $file_patch -pattern attachment
$Signature = Get-Content ($env:USERPROFILE + "\AppData\Roaming\Microsoft\Signatures\*.htm")
$rname = $name -replace ".*:"
$remail = $email -replace ".*:"
$rsubject = $subject -replace ".*:"
$rattachment = $attachment -replace ".*attachment:"
$rattachment
$sname = $rname -split ";"
$semail = $remail -split ";"
$ssubject = $rsubject -split ";"
$sattachment = $rattachment -split ";"
$body = Get-Content C:\M3_Outlook\PPS200.txt
$Signature = Get-Content ($env:USERPROFILE + "\AppData\Roaming\Microsoft\Signatures\*.htm")
$sRecipientAddr = $semail
$sMsgSubject = $ssubject
$oOutlook = New-Object -ComObject Outlook.Application
$oMapiNs = $oOutlook.GetNameSpace("MAPI")
$oMailMsg = $oOutlook.CreateItem(0)
$oMailMsg.GetInspector.Activate()
$sSignature = $oMailMsg.HTMLBody
$sSignature = $oMailMsg.HTMLBody
$sattachment | ForEach-Object { $oMailMsg.Attachments.Add($_) }
$oMailMsg.TO = $semail
$oMailMsg.Subject = $sMsgSubject
$oMailMsg.HTMLBody = $body + $sSignature
誰もがそのような行動の理由何ができるか知っていますそれを修正する方法は?
あなたが直面している問題は私には分かりません。あなたのコードのどの部分がうまくいかず、正確に「うまくいかない」、つまり、望ましい結果と実際の結果は何ですか? –